Re: sending array
| From: | Danielle van Gladbach | Date: | Wed, 15 Jan 2003 13:59:33 +0000 |
| Subject: | Re: sending array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131704@lists.php.net to get a copy of this message | ||
It works thanks!!!!
Here is the code, if anyone has the same problem:
test1.php
<?
$org["index-A"]=17010000;
$org["index-B"]=12090000;
$var=serialize($org);
$var=urlencode($var);
print "<a
href=\"test2.php?var=".$var."\">test2</a><BR>\n";
?>
test2.php
<?
$var=urldecode($var);
$org=unserialize($var);
while (list ($key, $val) = each($org))
{
print "key=".$key."val".$val."<br>\n";
}
?>
Jason Wong wrote:
> On Wednesday 15 January 2003 20:59, Danielle van Gladbach wrote:
>
> > I am trying to send an array from one php to another:
> >
> > $org["index-A"]=17010000;
> > $org["index-B"]=12090000;
> >
> > print "<a
> > href=\"test2.php?org=".$org."\">test2</a><BR>\n";
> >
> > But if I try to read te array in test2.php, I get "Warning: Variable
> > passed to each() is not an array ".
>
> You can't pass an array thru the URL. What you need to do is serialize() it
> then urlencode() it (or maybe rawurlencode()). Then you can put the resulting
> string in the URL.
>
> In test2.php you would unserialize() $org ($_GET['org']).
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> E Pluribus Unix
> */