php Getting the 'new' values in an array
- by Mark
Trying to learn about php's arrays today.
I have a set of arrays like this:
$a = array (
0 => array ( 'value' => 'America', ),
1 => array ( 'value' => 'England', ),
2 => array ( 'value' => 'Australia', ),
)
$b = array (
0 => array ( 'value' => 'America', ),
1 => array ( 'value' => 'England', ),
2 => array ( 'value' => 'Canada', ),
)
I need to get the 'new' subarrays that array b brings to the table.
ie, I need to return array ( 'value' => 'Canada', )
I thought I could first merge $a+$b and then compare the result to $a.
$merge = array_merge($a,$b);
$result = array_diff($merge,$a);
But somehow that does not work. It returns array()
How come? And thanks!