![]() |
| Home | Apache | PHP | Ubuntu | MySQL | Linux | HTML | Win | CSS | Perl | Javascript | Rants | Retro |
|
||
| How do I create a foreach loop in PHP The following code outputs the teams from the array in to a drop down menu. <?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>"; ?> |