note 19961 deleted from function.unserialize by sniper

From: Date: Mon, 13 Oct 2003 03:21:38 +0000
Subject: note 19961 deleted from function.unserialize by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58506@lists.php.net to get a copy of this message
Note Submitter: michael@cannonbose.com ---- Here's a couple of helper functions to convert arrays to URL strings and back. Special thanks to richard@richardhayes.net for the algorithms. /** * Array2URLString($array_in) * * Returns a serialized and encoded a array to be passed via the URL. * * @author Michael Cannon <michael@cannonbose.com> * @param array $array_in * @return string */ function Array2URLString($array_in) { $ser = serialize($array_in); $ser = urlencode($ser); return $ser; } /** * URLString2Array($url_string_in) * * Returns an array from a serialized and encoded URL string. * * @author Michael Cannon <michael@cannonbose.com> * @param array $url_string_in * @return string */ function URLString2Array($url_string_in) { $ser1 = stripslashes($url_string_in); $arr1 = urldecode($ser1); $arr1 = unserialize($arr1); return $arr1; } Example encoding: $ser_from = Array2URLString($form); // Sample URL creation Header("Location: http://www.example.com/thankyou.php?ser_form=" . $ser_from); Example decoding: // URL looks like this: // http://www.example.com/thankyou.php?ser_form=a%3A3... // Retrieve ser_form $body = URLString2Array($ser_form);

« previous php.notes (#58506) next »