ID:               33279
 Updated by:       [EMAIL PROTECTED]
 Reported By:      graced at monroe dot wednet dot edu
-Status:           Open
+Status:           Bogus
 Bug Type:         Arrays related
 Operating System: Linux 2.4.21/RHAS 3
 PHP Version:      5.0.4
 New Comment:

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Please *always* try latest snapshot before reporting a bug.
See bug #30833.


Previous Comments:
------------------------------------------------------------------------

[2005-06-08 21:23:33] graced at monroe dot wednet dot edu

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.

------------------------------------------------------------------------

[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

Reply via email to