bdd
08-11-2006, 12:52 AM
I'm into the part of my php book where it introduces arrays and the foreach loop statment.
Heres a example:
$days = range (1, 31);
echo '<select name="day">';
foreach ($days as $value) {
echo "<option value=\"$value\"> $value</option>\n";
}
I understand this script, the first part of the script echos HTML code to create the first drop-down menu with the '<select name="day">'; code. Thats where I get lost.
The book briefly explains the foreach statment in 3 sentences, not to which I comprehended.
I think it means, foreach (for each time) the $days array access a new value, it echos the below statment. Is this correct? Whats the "lamens term" for foreach, and how can you explain it in a sentence like for each blah blah blah. Thanks!
Heres a example:
$days = range (1, 31);
echo '<select name="day">';
foreach ($days as $value) {
echo "<option value=\"$value\"> $value</option>\n";
}
I understand this script, the first part of the script echos HTML code to create the first drop-down menu with the '<select name="day">'; code. Thats where I get lost.
The book briefly explains the foreach statment in 3 sentences, not to which I comprehended.
I think it means, foreach (for each time) the $days array access a new value, it echos the below statment. Is this correct? Whats the "lamens term" for foreach, and how can you explain it in a sentence like for each blah blah blah. Thanks!