PHP Tutorial : Looping numbers/array values
Jan 19, 2009 Basic PHP
Do you want to generate a lot of numbers in a range with a php loop? Or, you may want to generate a dynamic menu from a php array or something and dont know how to get out the values from this array.
Here is for the numbers, it can be done in two ways, using range function (only php 5) or manually estabilish them.
<?php for($i < 0; $i < 10; $i++) { print $i; } //or using range $nrs = range(0,10); foreach($nrs as $nr) { print $nr; } //Here is to extract from array $values = array("banana", "something", "apple"); foreach($values as $products) { print $products; } ?>
Tags: array, extract array values, loop, looping, php array, php array values, php loop, php looping


February 4th, 2009 at 3:10 pm
Hi,
Great job. But not enought info. Where can i read more?
Thanks
SonyaSunny
February 4th, 2009 at 4:03 pm
On the php official website!
May 16th, 2009 at 7:11 pm
Come on guys theres hardly and comments on this article!
May 16th, 2009 at 8:50 pm
O.K, you got me this is like my 3rd comment here today I cant wait for your next article!
May 17th, 2009 at 12:01 pm
I like that you update your blog quite a bit it keeps me coming back all the time.