note 104619 added to function.unserialize

From: Date: Sun, 26 Jun 2011 18:18:47 +0000
Subject: note 104619 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-180968@lists.php.net to get a copy of this message
If you are having troubles unserializing the string which contains dollars and single quotes, you can use this code: <?php $strParams = str_replace('$', '~', $strSerialized); $strParams = preg_replace('!s:(\d+):"(.*?)";!se', '"s:".strlen("$2").":\"$2\";"', $strParams); $strParams = str_replace('~', '$', $strParams); ?> Here is example array I had to deal with. It contains a list of parameters of a particular function: Array ( [0] => Array ( [type] => integer [name] => $varId ) [1] => Array ( [type] => boolean [name] => $blnMultiMode=false ) [2] => Array ( [type] => boolean [name] => $blnIsInsertTag=false ) [3] => Array ( [type] => string [name] => $strColumn='main' ) ) Thanks for "chris at r3i dot it" below! ---- Server IP: 195.114.0.19 Probable Submitter: 80.52.179.149 ---- Manual Page -- http://www.php.net/manual/en/function.unserialize.php Edit -- https://master.php.net/note/edit/104619 Del: integrated -- https://master.php.net/note/delete/104619/integrated Del: useless -- https://master.php.net/note/delete/104619/useless Del: bad code -- https://master.php.net/note/delete/104619/bad+code Del: spam -- https://master.php.net/note/delete/104619/spam Del: non-english -- https://master.php.net/note/delete/104619/non-english Del: in docs -- https://master.php.net/note/delete/104619/in+docs Del: other reasons-- https://master.php.net/note/delete/104619 Reject -- https://master.php.net/note/reject/104619 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#180968) next »