serialize() casts numeric string keys to integers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

Was wondering whether the fact that serialize() casts numeric string keys to integers, is a bug, intended behaviour, or just something that is minor enough not to have bothered anyone yet?

<?php

$arr1 = array('1'=>'string key'); // '1' will be casted to 1
$arr2 = array(1=>'integer key');

$arr1_uns = unserialize(serialize($arr1)) ;
$arr2_uns = unserialize(serialize($arr2)) ;

var_dump($arr1_uns, $arr2_uns);


==============================
array(1) {
  [1]=>
  string(10) "string key"
}
array(1) {
  [1]=>
  string(11) "integer key"
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux