PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hi guys. I am reading the learning php5 book and the following bit of code is used in one of the examples. However, when I run it I get the error:
Warning: Invalid argument supplied for foreach() in C:\wamp\www\Tests\test.php on line 40
I can select a single value from the option box and it will print it but I can't select multiple options and print them all by using the foreach function.
foreach() wants an array as first parameter. If it gets something else it will produce the warning
Warning: Invalid argument supplied for foreach()
If your script is called without the post parameter lunch[] (e.g. when you enter the url in your browser's locationbar), there will be no $_POST['lunch'] ...and that's not an array