Passing Arrays in Forms
Though it may not be apparent, it is possible to pass arrays from a form. To understand how, you must recall how form fields are turned into PHP variables. Each field is read in order by PHP and turned into an assignment statement. A URL like http://www.somesite.com/script.php3?name=leon creates an assignment like $name = "leon", which means that before the script begins executing, the name variable is set.
The name of the form field is treated as the left side of an assignment statement. This means that if other special characters appear as part of the name of the field, they will interpreted accordingly. You can include square brackets to force the variable to be an array. An empty pair of square brackets will add a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access