时间:2021-07-01 10:21:17 帮助过:4人阅读
//B数组比A数组少了一个元素
$a=array('a1','a2','a3','a4');
$b=array('a1','a2','a3');
$new=array_merge(array_diff($a, array_intersect($a, $b)), array_diff($b, array_intersect($a, $b)));
echo "";";
print_r($new);
echo "
/*
Array
(
[0] => a4
)
*/
//B数组比A数组多了一个元素
$a=array('a1','a2','a3');
$b=array('a1','a2','a3','b1','b2');
$new=array_merge(array_diff($a, array_intersect($a, $b)), array_diff($b, array_intersect($a, $b)));
echo "";";
print_r($new);
echo "
/*
Array
(
[0] => b1
[1] => b2
)
*/