foreach()
| From: | Anthony Ritter | Date: | Wed, 08 Sep 2004 14:20:55 +0000 |
| Subject: | foreach() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-196121@lists.php.net to get a copy of this message | ||
Greetings,
The following code is from "Learning PHP5 [O'Reilly] on page 90. Example -
6.5:
I get a:
Warning: Invalid argument supplied for foreach() in
c:\apache\htdocs\or_6.4.php on line 15
after submitting the form.
I'm not sure why since the example uses the call to foreach() in which the
array $lunch is passes through the call to retireve the values of the array
Thank you for your help.
TR
............
<form method="post" action="eat.php">
<select name="lunch[]" multiple>
<option value="pork">BBQ Pork Bun</option>
<option value="chicken">Chicken Bun</option>
<option value="lotus">Lotus Seed Bun</option>
<option value="pork">Bean Paste Bun</option>
<option value="chicken">Bird-Nest Bun</option>
</select>
<br><br>
<input type="submit" name="submit">
</form>
Selected buns:
<br>
<?
foreach ($_POST['lunch'] as $choice)
{
print "You want a $choice bun.<br>";
}
?>