You can take advantage of the fact that it array_searchreturns only one corresponding element from the target array and use it to remove from $array2:
$array1 = array(1.99);
$array2 = array(1.99, 1.99, 2.99);
foreach ($array1 as $remove) {
unset($array2[array_search($remove, $array2)]);
}
If it $array1may contain elements that are not present in $array2, then you need to add a check that the result is array_searchnot false.
iainn source
share