php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30833 array_count_values modifing input array
Submitted: 2004-11-19 00:20 UTC Modified: 2005-04-12 16:03 UTC
From: gms08701 at yahoo dot com Assigned: tony2001 (profile)
Status: Closed Package: Arrays related
PHP Version: 5.0.2 OS: FreeBSD 5.3
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: gms08701 at yahoo dot com
New email:
PHP Version: OS:

 

 [2004-11-19 00:20 UTC] gms08701 at yahoo dot com
Description:
------------
I recently upgraded to php 5.0.2 from 4.3.9.
The array that is input into array_count_values, is being 
modified.
Under 4.3.9, this function worked as expected.

Reproduce code:
---------------
<?php

header('content-type: text/plain');

$foo = array('abc', '0000');
var_export($foo);

echo "\n\n";

$count = array_count_values( $foo );
var_export($count);

echo "\n\n";

var_export($foo);

?>

Expected result:
----------------
array (
  0 => 'abc',
  1 => '0000',
)

array (
  'abc' => 1,
  '0000' => 1,
)

array (
  0 => 'abc',
  1 => '0000',
)

Actual result:
--------------
array (
  0 => 'abc',
  1 => '0000',
)

array (
  'abc' => 1,
  0 => 1,
)

array (
  0 => 'abc',
  1 => 0,
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-19 15:02 UTC] tony2001@php.net
This patch should fix the problem:
http://tony2001.phpclub.net/dev/tmp/bug30833.diff
 [2005-04-12 16:03 UTC] tony2001@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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 22 14:01:29 2025 UTC