ID: 29808
User updated by: php_bugs at michaeldouma dot com
Reported By: php_bugs at michaeldouma dot com
Status: Open
Bug Type: Arrays related
Operating System: MacOSX or Linux
PHP Version: 5.0.1
New Comment:
whoops, swapped Expected and Actual result
Previous Comments:
------------------------------------------------------------------------
[2004-08-24 08:01:09] php_bugs at michaeldouma dot com
Description:
------------
Similar to Bug�#28435 which should not be closed.
Can not access results from array_count_values when
counting strings which happen to be numbers.
Reproduce code:
---------------
$items1 = array (1,2,2,3,3,3);
$hist1 = array_count_values ($items1);
print "\nworks: ".join(",", $hist1);
print "\nworks: ".$hist1[1].",".$hist1[2].",".$hist1[3];
print "\nworks: ".$hist1["1"].",".$hist1["2"].",".$hist1["3"];
$items2 = array ("1","2","2","3","3","3","z","z");
$hist2 = array_count_values ($items2);
print "\nworks: ".join(",", $hist2);
print "\nfails: ".$hist2[1].",".$hist2[2].",".$hist2[3];
print "\nfails:
".$hist2["1"].",".$hist2["2"].",".$hist2["3"].",".$hist2["z"];
print "\n\n";
var_dump($hist1);
var_dump($hist2);
Expected result:
----------------
works: 1,2,3
works: 1,2,3
works: 1,2,3
works: 1,2,3,2
fails: ,,
fails: ,,,2
Actual result:
--------------
works: 1,2,3
works: 1,2,3
works: 1,2,3
works: 1,2,3,2
fails: 1,2,3
fails: 1,2,3,2
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29808&edit=1