Lets say I have the following two PHP arrays that contain integers:
$foo = array(1, 5, 9, 14, 23, 31, 45);
$bar = array(14, 31, 36);
I want to remove the items in $foo
where the same value exists in $bar
So the result of the process would create a $filteredFoo
array that contains:
1, 5, 9, 23, 45
Having looked through the docs on php.net there doesn't seem to be an existing function to perform this kind of action. So is my only option to use foreach and iterate through $foo
checking values $bar
on each iteration?