From:             ofirin at yahoo dot com
Operating system: Any
PHP version:      4CVS-2004-05-18 (stable)
PHP Bug Type:     Arrays related
Bug description:  array_count_values() problem

Description:
------------
I don't know if this is a php5 or php4 bug, but I'm sure something's wrong
here.
Whenever  in php5 I do an array_count_values() on an array that contains
numeric values as strings the result array uses string keys instead of the
numeric values as indexes. This doesn't happen in php4.
I don't know what behaivor is correct.
I'm using the latest cvs versions of both php4 and php5 btw.

Reproduce code:
---------------
<?php
$books = Array('10', '3', '6', '10');
$quantities = array_count_values($books);
var_dump($books);
var_dump($quantities);
?>

Expected result:
----------------
This is what happens in php4:

array(4) {
  [0]=>
  string(2) "10"
  [1]=>
  string(1) "3"
  [2]=>
  string(1) "6"
  [3]=>
  string(2) "10"
}
array(3) {
  [10]=>
  int(2)
  [3]=>
  int(1)
  [6]=>
  int(1)
}

Actual result:
--------------
This is what happens if php5:

array(4) {
  [0]=>
  string(2) "10"
  [1]=>
  string(1) "3"
  [2]=>
  string(1) "6"
  [3]=>
  string(2) "10"
}
array(3) {
  ["10"]=>
  int(2)
  ["3"]=>
  int(1)
  ["6"]=>
  int(1)
}

-- 
Edit bug report at http://bugs.php.net/?id=28435&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28435&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28435&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28435&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28435&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28435&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28435&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28435&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28435&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28435&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28435&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28435&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28435&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28435&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28435&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28435&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28435&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28435&r=float

Reply via email to