php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29808 array_count_values bungles strings which are numbers
Submitted: 2004-08-24 08:01 UTC Modified: 2004-08-26 02:26 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php_bugs at michaeldouma dot com
New email:
PHP Version: OS:

 

 [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 commitsRelated reports
 [2004-08-24 08:02 UTC] php_bugs at michaeldouma dot com
whoops, swapped Expected and Actual result
 [2004-08-26 02:26 UTC] iliaa@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC