note 56028 added to ref.url

From: Date: Sun, 21 Aug 2005 09:21:26 +0000
Subject: note 56028 added to ref.url
Groups: php.notes 
Request: Send a blank email to php-notes+get-93978@lists.php.net to get a copy of this message
You should have named your form field "organization[]" (notice the square brackets), instead of just organization. When using square brackets, the get/post request is interpreted by PHP as an array. If you follow this example you'll understand why it works the way it does: <?php $organization = 92; $organization = 93; // The second asignment overwrites the value of the first // asignment. $organization === 93. $organization[] = 92; $organization[] = 93; // The above is interpreted as appending data to an array // named "$organization". $organization is an array // consisting of the values 92 AND 93. ?> When submitting form fields with appended square brackets to their name, PHP interprets the submission using the same logic exposed above. Thus PHP automatically creates an array with all selected options if "$organization[]" is used as the field name. Regards, Daniel Berstein. ---- Manual Page -- http://www.php.net/manual/en/ref.url.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56028 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56028&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56028&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93978) next »