Re: passing arrays between pages
| From: | Thomas Reinke | Date: | Tue, 04 Jul 2000 17:11:29 +0000 |
| Subject: | Re: passing arrays between pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4781@lists.php.net to get a copy of this message | ||
I think you can get it to work the way you want if you change
the urlencode to base64_encode, and urldecode to base64_decode.
I'm not sure why, but when I tested this, the urlencode did ensure that
the data went through from one script to the next without change -
double quotes ended up having an extra "\" to escape them at the front.
Using the base64_encode seems to allow the entire serialized array
to be passed through as is, and successfully unserialized out the
back end.
Mind you, I tested this on a one dimensional array, but since your
example also failed for one dimensional array using urlencode,
I suspect its urlencode that is at fault.
Cheers, Thomas
Rasmus Lerdorf wrote:
>
> You can't pass an array like this. You have to loop through it and pass
> each element of the array separately.
>
> ie.
>
> <a href="url?arr[0][0]=One&arr[0][1]='Two'...
>
> -Rasmus
>
> On Wed, 5 Jul 2000, Nick Allan wrote:
>
> > Hi all
> > I'm having a problem passing a multidimentional array between pages.
> > The below example returns
> >
> > Newarr is of type boolean
> > Newarr[0] is of type NULL
> > Newarr[1] is of type NULL
> > Newarr[0][0] is
> > Newarr[0][1] is
> > Newarr[1][1] is
> > Newarr[1][2] is
> >
> > The code I'm using to test is as follows
> >
> > <?php
> >
> > if( !isset($passarr) ) {
> >
> > $arr[0][] = 'One';
> > $arr[0][] = 'Two';
> > $arr[0][] = 'Three';
> > $arr[1][] = 'Four';
> > $arr[1][] = 'Five';
> > $arr[1][] = 'Six';
> >
> > $passarr = urlencode(serialize($arr));
> >
> > echo "<a href=\"$PHP_SELF?passarr=$passarr\">Send
> > array</a>";
> > }
> > else
> > {
> > $newarr = unserialize(urldecode($passarr));
> >
> > echo 'Newarr is of type ' . gettype($newarr) . '<br>';
> > echo 'Newarr[0] is of type ' . gettype($newarr[0]) . '<br>';
> > echo 'Newarr[1] is of type ' . gettype($newarr[1]) . '<br>';
> >
> > printf("Newarr[0][0] is %s<br>",$newarr[0][0]);
> > printf("Newarr[0][1] is %s<br>",$newarr[0][1]);
> > printf("Newarr[1][1] is %s<br>",$newarr[1][1]);
> > printf("Newarr[1][2] is %s<br>",$newarr[1][2]);
> >
> > }
> >
> > ?>
> >
> > The TRACK-VARS variable according to phpinfo is on.
> > So what am I missing here?
> >
> > Thanks in advance for any suggestions.
> >
> > Regards Nick
> >
> >
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
------------------------------------------------------------
Thomas Reinke Tel: (905) 331-2260
Director of Technology Fax: (905) 331-2504
E-Soft Inc. http://www.e-softinc.com
Publishers of SecuritySpace http://www.securityspace.com