php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24198 array_merge_recurcive
Submitted: 2003-06-16 01:43 UTC Modified: 2003-06-16 12:37 UTC
From: camka at email dot ee Assigned: iliaa
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.3-dev/5.0.0-dev OS: win 2000
Private report: No CVE-ID:
 [2003-06-16 01:43 UTC] camka at email dot ee
Description:
------------
When var_dumping $f it appears a notice message, saying
Warning: array_merge_recursive(): recursion detected in ...
It is kind of strange because as far as I expect it is supposed to be the same result as in the line where $e is being var_dumped. var_dump($e) gives correct result:
array 
  'a' => 
    array 
      0 => 'aa' 
      1 => 'aa' 
  'b' => 
    array 
      0 => 'bb' 
      1 => 'bb'

and var_dump($f) gives notece message and result is 

array 
  'a' => 'aa' 
  'b' => 'bb'

problem appears in 4.3.1 too, but not in 4.2.2

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

$c=array('a' => 'aa','b' => 'bb'); 
$d=array('a' => 'aa','b' => 'bb'); 

$a=$c; 
$b=$c; 

$f=array_merge_recursive($a,$b); 
var_dump($f); 

$e=array_merge_recursive($c,$d); 
var_dump($e); 

?>

Expected result:
----------------
array 
  'a' => 
    array 
      0 => 'aa' 
      1 => 'aa' 
  'b' => 
    array 
      0 => 'bb' 
      1 => 'bb'

array 
  'a' => 
    array 
      0 => 'aa' 
      1 => 'aa' 
  'b' => 
    array 
      0 => 'bb' 
      1 => 'bb'

Actual result:
--------------
Warning: array_merge_recursive(): recursion detected in c:\servak\www\tests\array_merge_recursive.php on line 9

array
  'a' => 'aa'
  'b' => 'bb'

array
  'a' => 
    array
      0 => 'aa'
      1 => 'aa'
  'b' => 
    array
      0 => 'bb'
      1 => 'bb'



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-16 02:05 UTC] derick@php.net
Could verfiy this on both 4.3.2, 4.3.3-dev and 5.0.0-dev
 [2003-06-16 03:55 UTC] camka at email dot ee
just in case ...

the same warning appears when trying to merge one array with itself

array_merge_recursive($a,$a)
 [2003-06-16 12:37 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 07:02:14 2014 UTC