gabrielkolbe Posted June 22, 2006 Share Posted June 22, 2006 Hi I hope there is someone who can help me with this one. I have to pass a from one document to another, because of the program, I have to pass it via a string. I know how to do this ... But then in the doc where the string is passed to I have to get the variable out again, and it is here where I have a problem.I passs it like so:$valuex= $_REQUEST['valuex'];// place array ($valuex) in a string to pass values to charts.swf$xstring = "";foreach($valuex AS $key => $vax) {$xstring =$xstring."%26valuex%5B%5D=$vax"; }How do I get the value in the second document???I have tried this...$valuey = $_REQUEST["valuey"];$xstring = $_REQUEST["xstring"];$valuex = $_REQUEST["valuex"];(also tried placing a hidden field in the source doc)Would appreciate some help Link to comment https://forums.phpfreaks.com/topic/12641-passing-a-array-into-an-stringand-out-again/ Share on other sites More sharing options...
AV1611 Posted June 22, 2006 Share Posted June 22, 2006 maybe you can pass the variable via a session instead?that way you can call the variable anywhere during the session... Link to comment https://forums.phpfreaks.com/topic/12641-passing-a-array-into-an-stringand-out-again/#findComment-48484 Share on other sites More sharing options...
Wildbug Posted June 22, 2006 Share Posted June 22, 2006 Your problem isn't entirely clear to me from your post, but .... I'll try to help.Have you tried using serialize/unserialize ([a href=\"http://us2.php.net/manual/en/function.serialize.php\" target=\"_blank\"]manual page[/a]) instead of a hand-rolled function?You could serialize, store as a string in a hidden field, then unserialize() on POST. (Or in the URL for GET.)If it's just getting the array back into code, you'll need to either store it in a hidden field for a POST, or store it in the links on that page to retreive it as GET (you might need to use a urlencode() on it; I'm not sure). I.e., [code] <?php echo '<a href="http://...link.php?array="' . urlencode(serialize($array)) . '> to next page</a>';[/code](Are you using sessions? I guess not.) Link to comment https://forums.phpfreaks.com/topic/12641-passing-a-array-into-an-stringand-out-again/#findComment-48485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.