I have two arrays
$alpha=array('a','b','c','d','e','f');
$index=array('2','5');
I need to remove the items in the first array that has the index from the second array.
(Remove c-index is 2 and f-index is 5)
So that the returned array is
{'a','b','d','e'}
How can i do this using PHP? Thanks
Edit
Actually I need the final array as follows
[0]=>a
[1]=>b
[2]=>d
[3]=>e
Unsetting will return the array with same indexes
0 => string 'a' 
2 => string 'c' 
3 => string 'd' 
4 => string 'e' 
                foreach ($index as $key) {
    unset($alpha[$key]);
}
had it as array_unset() before.
Please, try this for more performance:
var_dump(array_diff_key($alpha, array_flip($index)));
                        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