nadeemshafi9 Posted February 24, 2009 Share Posted February 24, 2009 hi guys im working with a function calld invoke that calls a function method in reflections i need to pass an array eg XML or JSON and title throgh a url i know i can seperate these with many different charachters and put it into a url what is the best way any examples much thanks Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 best way is to use POST with a Post Body. if GET is the only option, you can serialize() and rawurlencode() it, then unserialize() it on the other end Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted February 24, 2009 Author Share Posted February 24, 2009 best way is to use POST with a Post Body. if GET is the only option, you can serialize() and rawurlencode() it, then unserialize() it on the other end what would you serialise it with ? what character ? Quote Link to comment Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 serialize it is a function. $array = array("item" => 1, 1 => "item"); $urlGET = rawurlencode(serialize($array)); header("Location: page.php?array={$urlGET}"); However, I would prefer to use POST or even sessions (if the page is on your server) to do this. To separate each item to avoid serialization: (The below assumes an associative array, with the index being the "variable" name.) $getData = array(); foreach ($array as $key => $val) { $getData[] = "{$key}={$val}"; } $urlQueryString = implode("&", $getData); header("Location: page.php?{$urlQueryString}"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.