Re: passing arrays between pages
| From: | Rasmus Lerdorf | Date: | Tue, 04 Jul 2000 16:30:28 +0000 |
| Subject: | Re: passing arrays between pages | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4770@lists.php.net to get a copy of this message | ||
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
>
>
>
>