From:             tomas_matousek at hotmail dot com
Operating system: WinXP
PHP version:      5.1.0RC1
PHP Bug Type:     Arrays related
Bug description:  array_merge_recursive merges objects with arrays

Description:
------------
Although one cannot pass obejects to array_merge_recursive() function, it
looks like it doesn't ignore objects at all.
If objects are contained in the array it merges them as if they were
arrays of fields. I think it is not good to treat objects in this way when
other array functions doesn't do so (e.g. array_walk_recursive doesn't step
to fields of objects).

Reproduce code:
---------------
class A 
{ 
  var $field = array(1);
}

$a = new A;
$x = array("a" => $a);

$y = array("a" => array("field" => array(2)));

var_dump(array_merge_recursive($x,$y));

Expected result:
----------------
array(1) {
  ["a"]=>
  array(2) {
    [0]=>
    object(A)#1 (1) {
      ["field"]=>
      array(1) {
        [0]=>
        int(1)
      }
    }
    ["field"]=>
    array(1) {
      [0]=>
      int(2)
    }
  }
}


Actual result:
--------------
array(1) {
  ["a"]=>
  array(1) {
    ["field"]=>
    array(2) {
      [0]=>
      int(1)
      [1]=>
      int(2)
    }
  }
}


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

Reply via email to