On Wed, Aug 15, 2012 at 1:35 PM, Kris Craig <kris.cr...@gmail.com> wrote:

>
>
> On Wed, Aug 15, 2012 at 1:31 PM, Nikita Popov <nikita....@gmail.com>wrote:
>
>> On Wed, Aug 15, 2012 at 10:29 PM, Kris Craig <kris.cr...@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
>>
>
> If you re-initialize it by setting it to array(), then yes that most
> definitely will clear all the values in the array.  As far as I know,
> array_keys() has nothing to do with that.
>
> --Kris
>
>
Err nevermind, I think I misread what you were trying to do.  If you want
to only clear a certain value, then yes using array_keys() with a search
value specified is the way to go.  If you want to clear all values in the
array period (which is what I thought you were saying), then
re-initializing with array() makes the most sense.

--Kris

Reply via email to