array_merge() doesn't work if there are objects in your array.

Here is a small test case.

<?php

class test
{
   var $one;
   var $two;

   function test($one, &$two) {
       $this->one = $one;
       $this->two = &$two;
   }
}

$x = 6;

$a = new test(1, &$x);
$b = new test(2, &$x);
$c = new test(3, &$x);

$aa = array($a, $b, $c);

$d = new test(4, &$x);
$e = new test(5, &$x);
$f = new test(1, &$x);

$bb = array($d, $e, $f);

$arr = array_merge($aa, $bb);  // array_merge_recursive doesn't do this
either

var_dump($arr);

?>

The results

array(6) {
  [0]=>
  object(test)(2) {
    ["one"]=>
    int(1)
    ["two"]=>
    &int(6)
  }
  [1]=>
  object(test)(2) {
    ["one"]=>
    int(2)
    ["two"]=>
    &int(6)
  }
  [2]=>
  object(test)(2) {
    ["one"]=>
    int(3)
    ["two"]=>
    &int(6)
  }
  [3]=>
  object(test)(2) {
    ["one"]=>
    int(4)
    ["two"]=>
    &int(6)
  }
  [4]=>
  object(test)(2) {
    ["one"]=>
    int(5)
    ["two"]=>
    &int(6)
  }
  [5]=>
  object(test)(2) {
    ["one"]=>
    int(1)
    ["two"]=>
    &int(6)
  }
}

It should only be a FIVE element array.  As elements 0 and 5 are exactly the
same.

I can only assume that this is beyond the scope of the function, but why?
Seems like it would be pretty easy to do.

-Chris


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to