Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 gabrielkolbe

gabrielkolbe
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 22 June 2006 - 03:28 PM

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

The Devil never lies..he just almost tell the truth

#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 22 June 2006 - 03:44 PM

maybe you can pass the variable via a session instead?

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

#3 Wildbug

Wildbug
  • Members
  • PipPipPip
  • Advanced Member
  • 1,149 posts

Posted 22 June 2006 - 03:44 PM

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.,
<?php echo '<a href="http://...link.php?array="' . urlencode(serialize($array)) . '> to next page</a>';

(Are you using sessions? I guess not.)
Twice a day my clock works PERFECTLY!  I can't figure out what's wrong with it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users