For each loop in php. The following code outputs the teams from the array in to a drop down menu.
| PHP Code: |
<?php
echo "<select name=\"teams\">";
// foreach example - loop through each entry in an array
$teams = array("Brighton","Luton","Swansea","Chelsea");
foreach ( $teams AS $elements )
{
print "<option value=\". $elements .\">". $elements ."</option>;/n";
}
echo "</select>";
?> |
|