|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-14 05:26 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Feb 11 06:00:01 2026 UTC |
Description: ------------ We have been using PHP 4.2.2 a while ago and saved serialized data in our database. Since we moved to PHP5 we had some problems unserializing some of this data. When "-1" (string) as an array key was used it appeared as a string in serialized form (PHP 4.2.2). PHP 4.3.10 and PHP 5.0.3 produce a serialized string with an integer. Using the PHP 4.2.2 generated data with PHP 4.3.10 works as expected but when we try to access the array using PHP 5.0.3 it doesn't work. That's really annoying. Reproduce code: --------------- 1. Script <?php print serialize(array("-1"=>-1))."\n"; ?> 2. Script <?php $string='a:1:{s:2:"-1";s:2:"-1";}'; $arr=unserialize($string); var_dump($arr["-1"]); var_dump($arr[-1]); ?> // PHP 4.2.2 and PHP 4.3.10 => OK // PHP 5.0.3 => both are NULL Expected result: ---------------- PHP 5.0.3 should return -1 in both cases Actual result: -------------- PHP 5.0.3 returns NULL