Re: removing an item from an array
| From: | Nikita Popov | Date: | Wed, 15 Aug 2012 20:31:20 +0000 |
| Subject: | Re: removing an item from an array | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62206@lists.php.net to get a copy of this message | ||
On Wed, Aug 15, 2012 at 10:29 PM, Kris Craig <kris.craig@gmail.com> wrote:
>>
>> Btw, deleting all values (not just the first) is also very easy currently:
>>
>> foreach (array_keys($array, $delValue) as $key) {
>> unset($array[$key]);
>> }
>>
>
> Even easier still, just do this:
>
> $array_var = array();
It's often overlooked, but array_keys has a second parameter that only
returns the keys for a certain value: http://php.net/array_keys ;) So
no, that does not clean off the whole array.
Nikita