Passing Arrays in URLs. I.e passing arrays between two pages.
This has been delt with before but I can't help feeling there is a better way. The current options are:
serialize and urlencode .... then ... urldecode and unserialize
OR
implode ... then ... explode
OR
use session variables/cookies
But if you create a form with a multiple select in it like so:
<SELECT NAME=selectname[]> etc
.. the array $selectname appears automatically in the backend when the form is submitted. Note that $selectname is an array. This means that php must automatically create arrays from data POSTed in a particular format.
If we could pass an array in this format in a url or a hidden form then we wouldn't have to do anything on the recieving page.
Anyone know what this format is?
Passing Arrays in URLs - A Better Way?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Re: Passing Arrays in URLs - A Better Way?
Sessions. You have three choices for passing data between pages - GET, POST and sessions/cookies, only sessions can pass arrays without any manipulation needed on either end of the processing.alexp wrote:Anyone know what this format is?
Mac
But the multiple select array is not passed using session cookies - it is passed in the POST along with all the other variables - and it is reconstructed automatically by PHP at the other end. Clearly there is some formatting of a POST variable that triggers the PHP engine into processing it as an array.