note 6060 modified in unserialize by ronabop
| From: | ronabop@php.net | Date: | Sun, 03 Sep 2000 11:04:00 +0000 |
| Subject: | note 6060 modified in unserialize by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4067@lists.php.net to get a copy of this message | ||
The problem I was concerned with was one where an array of query strings (i.e. form elements that
had slashes automatically added) was being serialized. In that case,
unserialize(stripslashes($myarray)) would not work, because it had been serialized with the slashes
in the array elements (and therefore the element length info in the serialized data includes the
slashes). One has to remove the slashes *from each array element* before serializing it. So:
<PRE>
function stripEach(&$element) {
$element = stripslashes($element);
}
array_walk($myarray, "stripEach");
$serializedarray = serialize($myarray);
# now addslashes() / stripslashes() can be safely
# aplied to $serializedarray
</PRE>
http://www.php.net/manual/function.unserialize.php