Follow:  Follow PHPExercises on Twitter  Follow us on Facebook

PHP Functions Ex. #5: Variable Argument Number

For this PHP exercise, you will again write two versions of your script. Start with the script from Arrays Ex. #3 and write a function to create form checkbox elements from the arguments supplied. This function should be able to take a variable number of arguments so that you can create any number of checkboxes calling it only once. Add your function at the beginning of your file before the HTML. Make sure each item is upper case.

Now rewrite the original form presented to the user with the checkbox function. Make sure the list returned to the user in the second part of the script is also upper case.



Hi, it's a problem on line 58. I think my php can't get the $_POST['weather'] from

echo "<input type=\"checkbox\" name=\"weather[]\" value=\"$a\" />" 

A solution?

Thanks. It really helps me this website

Thanks for pointing this out. We've made a change to the code in lines 58 and 59 of the first script. This should get your code working.

See this comment for an explanation.