Well, I have
$a2 = array('a'=>'Apple','b'=>'bat','c'=>'Cat','d'=>'Dog','e'=>'Eagle','f'=>'Fox','g'=>'God');
$a3 = array('b','e');
I want to substract $a3 from $a2 to get:
$aNew = array('a'=>'Apple','c'=>'Cat','d'=>'Dog','f'=>'Fox','g'=>'God');
Any help?
the are two built-in functions to do something similar: array_diff and array_diff_assoc - but both won't work in your case.
so, to do what you want, you'll have to change the markup of your $a3 a bit to fit these functions (take a look at the documentation), or you'll have to loop $a3 and delete the elements from $a2 manually like this:
foreach($a3 as $k){
unset($a2[$k]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With