Forum Moderators: coopster
And array_diff should work, too.
You can also change the original arrays....
$a = array_diff($a,$b);
$b = array_diff($b,$a);
// input
$a = [1,2,3,4,5,6,7,8]
$b = [2,4,6,8,10,12]
// execute line 1
$a = array_diff($a,$b);
// temp values
$a = [1,3,5,7]
$b = [2,4,6,8,10,12]
// execute line 2
$b = array_diff($b,$a);
// output
$a = [1,3,5,7]
$b = [2,4,6,8,10,12]
so, at the end $b contains values that were originally present in $a, which ought to have been removed
$array1 = array(1,2,3,4,5,6,7,8);
$array2 = array(2,4,6,8,10,12);
$new_array = array();
$temp = array_merge((array)$array1, (array)$array2);
$temp = array_count_values($temp);
foreach($temp as $key => $val){
if($val == 1) $new_array[] = $key;
}
This function is essential for solving this problem [webmasterworld.com], involving summation of inherited properties in a hierarchy