ID: 33279 User updated by: graced at monroe dot wednet dot edu Reported By: graced at monroe dot wednet dot edu Status: Open Bug Type: Arrays related Operating System: Linux 2.4.21/RHAS 3 PHP Version: 5.0.4 New Comment:
For what it's worth, *this* works: var_dump(array("012345" => 'yay')); array(1) { ["012345"]=> string(3) "yay" } so it looks like it's an issue with array_count_values() itself and not something at a deeper level. Previous Comments: ------------------------------------------------------------------------ [2005-06-08 19:35:24] graced at monroe dot wednet dot edu Description: ------------ See: bug #28435 array_count_values() problem http://www.php.net/manual/en/language.types.array.php array_count_values() casts numeric strings (i.e. "72") to integers (72). This is correct (although annoying) behavior as described at http://www.php.net/manual/en/language.types.array.php, except for one catch. The documentation states (emphasis mine) "If a key is the standard representation of an integer, it will be interpreted as such (i.e. "8" will be interpreted as 8, ***while "08" will be interpreted as "08"***). However, array_count_values() will strip the leading zeroes and turn those strings into integers, which causes errors in code later on when (string) 8 is compared against (string) "08" and the comparison fails. Reproduce code: --------------- <?php var_dump(array_count_values(array("012345"))); Expected result: ---------------- array(1) { ["012345"]=> int(1) } Actual result: -------------- array(1) { [12345]=> int(1) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33279&edit=1