note 103793 added to function.unserialize

From: Date: Wed, 04 May 2011 00:45:22 +0000
Subject: note 103793 added to function.unserialize
Groups: php.notes 
Request: Send a blank email to php-notes+get-179394@lists.php.net to get a copy of this message
The code chaos submitted mostly worked but broke when storing floating point numbers. The following change fixed it for me: $serialized = preg_replace_callback( '!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|d:|i:|o:|N;))!s', 'serialize_fix_callback', $serialized ); function serialize_fix_callback($match) { return 's:' . strlen($match[2]); } Just added d: to the regex, as that's the index used for floating point (digits) ---- Server IP: 69.147.83.197 Probable Submitter: 68.2.106.199 ---- Manual Page -- http://www.php.net/manual/en/function.unserialize.php Edit -- https://master.php.net/note/edit/103793 Del: integrated -- https://master.php.net/note/delete/103793/integrated Del: useless -- https://master.php.net/note/delete/103793/useless Del: bad code -- https://master.php.net/note/delete/103793/bad+code Del: spam -- https://master.php.net/note/delete/103793/spam Del: non-english -- https://master.php.net/note/delete/103793/non-english Del: in docs -- https://master.php.net/note/delete/103793/in+docs Del: other reasons-- https://master.php.net/note/delete/103793 Reject -- https://master.php.net/note/reject/103793 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179394) next »