Jump to content


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


passing a array into an string..and out again..

Recommended Posts

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

Share this post

Link to post
Share on other sites
maybe you can pass the variable via a session instead?

that way you can call the variable anywhere during the session...

Share this post

Link to post
Share on other sites
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.)

Share this post

Link to post
Share on other sites


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.