10/12/2012

array_diff not support ojbect

array_diff for parameters does not support objects


e.g.
$a = array(
   'a',
   'b',
);
$b = array(
   'b',
   'c'
);

$c = array_diff($a, $b);

$c = array(1=>'b');

------------------------------

for object, 

$a = array(
   new stdClass(),
   'b',
);
$b = array(
   'b',
   'c'
);

$c = array_diff($a, $b);

you will get error message
Catchable fatal error: Object of class stdClass could not be converted to string in...............

No comments:

Post a Comment