By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,712 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,712 IT Pros & Developers. It's quick & easy.

passing Multidimensional array thru the URL

P: n/a
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.
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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));

Jul 17 '05 #2

P: n/a
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
Jul 17 '05 #3

P: n/a
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

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.