- array_intersect: documentation ( source)
- print_r: documentation ( source)
- array_diff: documentation ( source)
<?php
$all = [
'1',
'2',
'3',
'4',
];
$new = [
'3',
'2',
'5',
];
$toRemove = array_diff($all, $new);
$toAdd = array_intersect($all, $new);
print_r($toAdd);
print_r($toRemove);