#29808 [Opn->Csd]: array_count_values bungles strings which are numbers
| From: | iliaa@php.net | Date: | Thu, 26 Aug 2004 00:26:30 +0000 |
| Subject: | #29808 [Opn->Csd]: array_count_values bungles strings which are numbers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-65258@lists.php.net to get a copy of this message | ||
ID: 29808
Updated by: iliaa@php.net
Reported By: php_bugs at michaeldouma dot com
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: MacOSX or Linux
PHP Version: 5.0.1
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-08-24 08:02:39] php_bugs at michaeldouma dot com
whoops, swapped Expected and Actual result
------------------------------------------------------------------------
[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