#28435 [Opn->Csd]: array_count_values() problem
ID: 28435
Updated by: hholzgra@php.net
Reported By: ofirin at yahoo dot com
-Status: Open
+Status: Closed
Bug Type: Arrays related
Operating System: Any
PHP Version: 5.0.1
New Comment:
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
Fixed in 5.0.2
Previous Comments:
------------------------------------------------------------------------
[2004-08-24 15:55:22] ofirin at yahoo dot com
I'm opening back this bug again because I think the last user's
submition needs revision.
------------------------------------------------------------------------
[2004-08-24 07:43:06] php_bugs at michaeldouma dot com
Why is this bug closed? I am now experiencing the same
problem with 5.0.1. The array from array_count_values
appears normal with vardump, but there is no way to
access the elements; neither as arrayname["2"] nor
arrayname[2]. This worked fine with 4.3.x.
vardump of result from array_count_values
array(5) {
["3"]=>
int(2)
["2"]=>
int(1)
["1"]=>
int(1)
["0"]=>
int(1)
[0]=>
int(0)
}
It looks like you'd be able to access the value with
arrayname["2"], but you can't!
------------------------------------------------------------------------
[2004-08-04 16:39:13] alexis dot bosson at medias dot cnes dot fr
As said in :
- bug #9307
- bug #21918
- bug #22201
- and documentation of arrays :
http://www.php.net/manual/en/language.types.array.php
" If a key is the standard representation of an integer, it will be
interpreted as such (i.e. "8" will be interpreted as 8, while "08" will
be interpreted as "08"). "
So the array_count_values must cast the integers contained in strings
to integers.
Actually, with standard PHP behavior, it's impossible to access
directly to those array elements which keys are strings containing
integers, as said in comment of June 18
------------------------------------------------------------------------
[2004-06-21 17:50:47] ofirin at yahoo dot com
Ok, I think you're right, we all should be looking forward working with
php5, rather than trying to fix old bugs in php4.
------------------------------------------------------------------------
[2004-06-21 11:31:59] vladb at pseudo-infinity dot ro
The php5 result seems more accurate than the php4 one. You got strings
in the $books array, no?
Changing this in php4 may break some code out there so maybe it'd be
best to just mention it as a 4-5 inconsistency.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/28435
--
Edit this bug report at http://bugs.php.net/?id=28435&edit=1
Thread (8 messages)