O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.6. 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. An URL such as http://www.example.com/script.php?name=leon executes an assignment like $name = "leon". By default, PHP places these assignments into a set of associative arrays.

PHP treats the name of the form field as the left side of an assignment statement. This means that if other special characters appear as part of the name of the field, PHP interprets them accordingly. You can include square brackets to force the variable to be an array. An empty pair of square brackets will add ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required