Re: order of elements in $_POST super global
| From: | Ben Liu | Date: | Fri, 09 Jun 2006 13:00:49 +0000 |
| Subject: | Re: order of elements in $_POST super global | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237683@lists.php.net to get a copy of this message | ||
Hi Mindaugas,
I wasn't trying to imply that there was something wrong or illogical about the way the $_POST variable is processed. It is logical that it processes in the order listed in html. Perhaps I should have said, "my problem" rather than "the problem". I'll be sure to read about the bug you mention. Thanks.
- BL
On Jun 9, 2006, at 8:54 AM, Mindaugas L wrote:
Attachment: [application/pkcs7-signature] smime.p7s
Hello, " The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. " I think it's very natural behaviour. But be careful with associative arrays, I think before version 5.12.there was a bug, if you want that PHP makes an associative array of form elements. http://bugs.php.net/bug.php?id=37276 Enjoy Mindaugas On 6/9/06, Ben Liu <blzabub8@gmail.com> wrote:Hi Mike, Thanks for pointing that out. I hadn't thought of it but you are right. But I still don't think this addresses the issue of ordering. The basic problem is that the way a $_POST variable gets processed is in the order it is in on the original form. If you want to present the fields in one manner and process them in a different order, you have to either use styling tricks to change the presentation order or use some post processing to change the order of the array or use potentially a ton of "if" statements or as Joao suggests, a long "switch" statement. Anyhow, thanks for the tip. - BL On 6/9/06, Ford, Mike <M.Ford@leedsmet.ac.uk> wrote:I know you've found another (perfectly good) solution already,but I just wanted to point out that you could have used the above scenario with the names as the array indexes, like:<input type="checkbox" name="bool_questions[first_name]"value="yes">The above input shows up in $_POST['bool_questions']['first_name'], so you could iterate over $_POST['bool_questions'] to get the result you want.-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php--Mindaugas
Attachment: [application/pkcs7-signature] smime.p7s