Re: Header() variables

From: Date: Thu, 10 Apr 2003 10:12:24 +0000
Subject: Re: Header() variables
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-143302@lists.php.net to get a copy of this message
I've fixed, really really!! here is the stealed code (from php.net user examples) first page code: ------------------------------ function Array2URLString($array_in) { $ser = serialize($array_in); $ser = urlencode($ser); return $ser; } $myArray=array("index1" => "element1", "index2" => "element2"); $serilized_string = Array2URLString($myArray); header("Location: target_file.php?myArray=".$serialized_string); ------------------------------ in target_file will decode the urlencoded-serialized string: ------------------------------ function URLString2Array($url_string_in) { $ser1 = stripslashes($url_string_in); $arr1 = urldecode($ser1); $arr1 = unserialize($arr1); return $arr1; } $new_array = URLString2Array($myArray); ------------------------------ NOW the $new_array will contains the same structure as $myArray variable from first page. Thank alot for your help, I couldn't have done it without you!!! ----- Original Message ----- From: Leif K-Brooks To: Alex Ciurea Cc: php mailing ; Erwin Kerk Sent: Thursday, April 10, 2003 12:36 PM Subject: Re: [PHP] Header() variables You should also urlencode() it, as in header("Location: target_file.php?myVar=".urlencode(serialize($myVar))); Alex Ciurea wrote: Thx alot, now I've fixed the problem: header("Location: target_file.php?myVar=".serialize($myVar)); In target_file I use $myVar=unserialize($myVar) to regain my variable. It works now. Again, thank you very much for your help. Alex ----- Original Message ----- From: "Erwin Kerk" <erwin@scoutingnederland.nl> To: "Alex Ciurea" <alex@netonwave.com> Sent: Thursday, April 10, 2003 12:13 PM Subject: Re: [PHP] Header() variables Try the serialize() and unserialize() functions Erwin Alex Ciurea wrote: Hello, I try to send some variables using the header() function. My code is: header("Location: target_file.php?myVar=".$myVar); It works fine with all types of variables, but not with arrays. If $myVar is an array, the header function will transmit the value "Array". Probably it's normal but is there any way to transmit an array using this function ?? Thanks alot Alex -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.

« previous php.general (#143302) next »