I have two arrays. I need to remove an element from the first array when the element is included in the second array.
e.g.:
$First = array("apple"=>"7", "orange"=>"8", "strawberry"=>"9", "lemon"=>"10", "banana"=>"11");
$Second = array("orange"=>"1", "lemon"=>"1","banana"=>"1");
$Result = array("apple"=>"7","strawberry"=>"9");
I've used the following code but it is not working:
foreach($Second as $key){
$keyToDelete = array_search($key, $First);
unset($First[$keyToDelete]);
}
print_r($First);