Jump to content

is it possible to pass an array variable through the URL?


co.ador

Recommended Posts

you can either pass it by serializing it like rajivgonsalves said or you could actually pass it as an array.

 

ex. serialize

$pass = serialize($array);
echo '<a href="test.php'.$pass.'">test</>';

 

ex. array

echo '<a href="test.php?arr[]=test1&arr[]=test2">test</a>';

thank you guys for the examples...

 

How do I get a serialize array variable in the page being pass to?

 

for instance this is the case of test.php, what is the method of receiving the values of the $pass serialize variable?

something like this on the page you are passing the variable

 

$array = array('test'=>'best', 'mest' => 'lest');
$pass = serialize($array);
echo '<a href="test.php?var='.base64_encode(($pass)).'">test</>';

 

on the page your retrieving it

 

$var = unserialize(base64_decode($_GET['var']));
print_r($var);

 

Although keep in mind Get has a limit of 4k I think so if the array is too big it might cut out you might want to send it through post.

$array = unserialize($_GET['var']);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.