Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php elegance keys unsetting

I need to remove from an array some keys.

$array = array('a' => 'a', 'b' => 'b', 'c' => 'c');
unset($array['a']);
unset($array['b']);

How can I do this more elegance? Maybe there is a function like this array_keys_unset('a', 'b')?
I don't need array_values or foreach. I only want to know is it possible.
Thank you in advance. Sorry for my english and childlike question.

like image 915
Alex Pliutau Avatar asked Dec 10 '10 14:12

Alex Pliutau


1 Answers

You can do that with single call to unset as:

unset($array['a'],$array['b']);
like image 73
codaddict Avatar answered Sep 17 '22 21:09

codaddict