Jump to content

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


gabrielkolbe

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.