samir
Joined: 12 Nov 2007 Posts: 232
|
Posted: Sun Jun 28, 2009 11:47 am Post subject: quick and easy loop |
|
|
If you want to create a quick and easy loop to show the values of an array, then all you need is the trusty foreach control structure, thus:
<?php
$alphabet = range("A","Z");
foreach($alphabet as $letter) { echo "Ooh look! The letter $letter\n"; }
?>
Prints this:
Ooh look! The letter A
Ooh look! The letter B
Ooh look! The letter C
Ooh look! The letter D
Ooh look! The letter E
Ooh look! The letter F
Ooh look! The letter G
Ooh look! The letter H
Ooh look! The letter I
Ooh look! The letter J |
|