co.ador Posted December 12, 2009 Share Posted December 12, 2009 Want to know your opinion on that the variable is $arrRestaurants and the url string would be? herf=" restaurantsresults.php?restaurants=$arrRestauratns" is the above string correct? Link to comment https://forums.phpfreaks.com/topic/184862-is-it-possible-to-pass-an-array-variable-through-the-url/ Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2009 Share Posted December 12, 2009 nope can't do that, you can implode it and pass it thats if it is an array without keys or you can serialize it and pass it Link to comment https://forums.phpfreaks.com/topic/184862-is-it-possible-to-pass-an-array-variable-through-the-url/#findComment-975828 Share on other sites More sharing options...
ngreenwood6 Posted December 12, 2009 Share Posted December 12, 2009 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>'; Link to comment https://forums.phpfreaks.com/topic/184862-is-it-possible-to-pass-an-array-variable-through-the-url/#findComment-975837 Share on other sites More sharing options...
co.ador Posted December 12, 2009 Author Share Posted December 12, 2009 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? Link to comment https://forums.phpfreaks.com/topic/184862-is-it-possible-to-pass-an-array-variable-through-the-url/#findComment-975960 Share on other sites More sharing options...
rajivgonsalves Posted December 12, 2009 Share Posted December 12, 2009 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']); Link to comment https://forums.phpfreaks.com/topic/184862-is-it-possible-to-pass-an-array-variable-through-the-url/#findComment-975978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.