array_count_values bungles strings which are numbers
| Bug #29808 | array_count_values bungles strings which are numbers | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-08-24 08:01 UTC | Modified: | 2004-08-26 02:26 UTC |
|
||||||||||
| From: | php_bugs at michaeldouma dot com | Assigned: | ||||||||||||
| Status: | Closed | Package: | Arrays related | |||||||||||
| PHP Version: | 5.0.1 | OS: | MacOSX or Linux | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-08-24 08:01 UTC] 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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-08-24 08:02 UTC] php_bugs at michaeldouma dot com
[2004-08-26 02:26 UTC] iliaa@php.net