Home > Archive > PHP Programming > May 2005 > passing Multidimensional array thru the URL
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
passing Multidimensional array thru the URL
|
|
|
| Hi All,
I have an issue with an array that I would to pass to a second php
script; please note that I cannot use session.
I have been looking at the functions : rawurlencode / rawurldecode
urlencode / urldecode
but it does not seems to work for my variable
here is an example of variable
<?
$x=0;
$data[$x][title]="My title";
$data[$x][label]=array("label1","label2","label3");
$data[$x][data]=array(100,150,145);
?>
How can I pass this variable thru an URL ?
FYI, the need is to generate a graph with JpGraph
(http://www.aditus.nu/jpgraph/)
I would appreciate any feedback
Please advise,
Thanks
Jack.
| |
| ZeldorBlat 2005-05-27, 8:55 pm |
| Check out serialize() and unserialize() :
http://www.php.net/serialize
http://www.php.net/unserialize
They basically let you take any type of variable (objects, arrays,
etc....but not resource handles) and turn them into a string. So, on
your first page you might have:
$url_data = urlencode(serialize($data));
and on the second page:
$data = unserialize(urldecode($url_data));
| |
|
| ZeldorBlat wrote:
> Check out serialize() and unserialize() :
>
> http://www.php.net/serialize
> http://www.php.net/unserialize
>
> They basically let you take any type of variable (objects, arrays,
> etc....but not resource handles) and turn them into a string. So, on
> your first page you might have:
>
> $url_data = urlencode(serialize($data));
>
> and on the second page:
>
> $data = unserialize(urldecode($url_data));
>
Arf !
Stupid me !!!
I did use the same code, but on the second page I did not reverse the
code such as
urldecode(unserialize($url_data));
instead of unserialize(urldecode($url_data));
I tested and it worked.
Thank much you for opening my eyes
:-D
| |
| R. Rajesh Jeba Anbiah 2005-05-30, 3:56 am |
| Jack wrote:
> I have an issue with an array that I would to pass to a second php
> script; please note that I cannot use session.
> I have been looking at the functions : rawurlencode / rawurldecode
> urlencode / urldecode
> but it does not seems to work for my variable
>
> here is an example of variable
> <?
> $x=0;
> $data[$x][title]="My title";
> $data[$x][label]=array("label1","label2","label3");
> $data[$x][data]=array(100,150,145);
>
> ?>
>
> How can I pass this variable thru an URL ?
<snip>
http://www.example.com/test.php?data[0][title]=My%20title&data[0][label][]=label1&data[0][label][]=label2&data[0][label][]=label3&data[0][data][]=100&data[0][data][]=150&data[0][data][]=145
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com
|
|
|
|
|