473,395 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Jul 17 '05 #1
3 4752
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mark Smith | last post by:
I'm trying to copy data from a 1D array to a 2D array. The obvious thing doesn't work: int twoDee = new int; int oneDee = new int { 1, 2 }; Array.Copy(oneDee, 2, twoDee, 2, 2); This causes a...
3
by: Claire | last post by:
I have a multidimensional array defined as private double myArray = new double; The first column of the array contains X values, the other contains Y values I have a charting function defined as...
21
by: vmsgman | last post by:
Here is a code sample ... int blah = ReadFile( defArray, defFileName, w, h); // Read File Contents into memory array and return for processing public int ReadFile( ref ushort nArray, string...
2
by: nleahcim | last post by:
Hi - I am working on writing a number of matrix manipulation functions. The most basic one was a printing algorithm - and it shows the problem I'm having. I'm passing it a pointer a mutidimensional...
14
by: Michel Rouzic | last post by:
Hi, I've recently met issues with my program which can only be explained by heap corruption, so I've tried debugging my program with Valgrind, and here's what I get with the following...
2
by: nitinm | last post by:
hi I want to make a program whose requirement are as following: 1) it has to create an NxN matrix after reading input (i.e. N) from a file in the main() itself. 2) it has to send the array as...
6
by: themadme | last post by:
hi, im trying to create a multidimensional array and then pass along a few funcitons. this is the way i have created, im sure its the correct way of doing it? // TerrainMapData is struct ...
2
by: ...vagrahb | last post by:
I am having accessing individual rows from a multidimensional array pass to a function as reference CODE: function Declaration int Part_Buffer(char (*buffer),int Low, int High)
1
by: Szabolcs Borsanyi | last post by:
The following code compiles with a warning message: passing arg 1 of `use_vector' from incompatible pointer type How can one correctly pass a multidimensional array (by reference) expressing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.