From: php_bugs at michaeldouma dot com
Operating system: MacOSX or Linux
PHP version: 5.0.1
PHP Bug Type: Arrays related
Bug description: array_count_values bungles strings which are numbers
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 bug report at http://bugs.php.net/?id=29808&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29808&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29808&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29808&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=29808&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29808&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29808&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29808&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29808&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29808&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29808&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29808&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29808&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29808&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29808&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29808&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29808&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29808&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29808&r=float