note 19054 added to function.unserialize
| From: | phee_hates_spam at isthisthingon dot org | Date: | Thu, 14 Feb 2002 02:06:12 +0000 |
| Subject: | note 19054 added to function.unserialize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26601@lists.php.net to get a copy of this message | ||
Here you go, free to the world. My contribution to help deal with serialized data that contains
backslashes. Add these two functions to your code:
function bs_shuffle(&$in) {
// The Backslash Shuffle, as I like to call it.
preg_replace('/\\/', '#BS#', &$in);
}
function bs_unshuffle(&$in) {
// ...and the corresponding Unshuffle.
preg_replace('/#BS#/', '\\', &$in);
}
Now, your variables will have *no* backslashes in them when you serialize them. Run
bs_shuffle(&$var) (don't forget the "&"), then serialize($var)... when you
retrieve it later, you can bs_unshuffle(&$var) and it's back to its backslashed self.
--
http://www.php.net/manual/en/function.unserialize.php
http://master.php.net/manage/user-notes.php?action=edit+19054
http://master.php.net/manage/user-notes.php?action=delete+19054
http://master.php.net/manage/user-notes.php?action=reject+19054