php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42655 array_walk_recursive() leaves references
Submitted: 2007-09-13 11:08 UTC Modified: 2007-10-02 12:08 UTC
From: ltaupiac at lfdj dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5CVS-2007-09-13 (snap) OS: *
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: ltaupiac at lfdj dot com
New email:
PHP Version: OS:

 

 [2007-09-13 11:08 UTC] ltaupiac at lfdj dot com
Description:
------------
Using array_walk_recursive leaves references on source array.

Reproduce code:
---------------
$data = array ('key1' => 'val1', array('key2' => 'val2'), 'key3' =>'val3');

function foo($item, $key){}

var_dump($data);
array_walk_recursive($data,'foo');
var_dump($data);


Expected result:
----------------
array(3) {
  ["key1"]=>
  string(4) "val1"
  [0]=>
  array(1) {
    ["key2"]=>
    string(4) "val2"
  }
  ["key3"]=>
  string(4) "val3"
}
array(3) {
  ["key1"]=>
  string(4) "val1"
  [0]=>
  array(1) {
    ["key2"]=>
    string(4) "val2"
  }
  ["key3"]=>
  string(4) "val3"
}

Actual result:
--------------
array(3) {
  ["key1"]=>
  string(4) "val1"
  [0]=>
  array(1) {
    ["key2"]=>
    string(4) "val2"
  }
  ["key3"]=>
  string(4) "val3"
}
array(3) {
  ["key1"]=>
  string(4) "val1"
  [0]=>
  &array(1) {
    ["key2"]=>
    string(4) "val2"
  }
  ["key3"]=>
  string(4) "val3"
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-02 12:08 UTC] tony2001@php.net
See bug #34982.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Mar 13 07:01:30 2025 UTC