note 19127 deleted from function.unserialize by sniper

From: Date: Mon, 13 Oct 2003 03:21:26 +0000
Subject: note 19127 deleted from function.unserialize by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58504@lists.php.net to get a copy of this message
Note Submitter: phee_hates_spam@isthisthingon.org ---- 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: bs_shuffle(&$variable); function bs_shuffle($in) { $in=preg_replace('/\\/', '#BS#', $in); } function bs_unshuffle($in) { $in=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.

« previous php.notes (#58504) next »