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
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-02 12:08 UTC] tony2001@php.net
See bug #34982.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 04:01:27 2019 UTC