Re: Proper way to remove an element from an array
| From: | Richard Lynch | Date: | Wed, 11 Jul 2007 21:43:22 +0000 |
| Subject: | Re: Proper way to remove an element from an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258652@lists.php.net to get a copy of this message | ||
On Tue, July 10, 2007 4:23 pm, Dan wrote:
> I know in some languages there's a right way to remove an element from
> an
> array and other ways that will give you problems.
>
> In PHP can I just set $arrayname[key] = null? Or will I then end up
> with
> key => null as a value. I looked on php.net under array functions for
> a bit
> and I didn't find any sort of remove element function. I've just
> never
> needed to do this before.
http://php.net/unset
Setting to null should also work, I think, but only in some versions...
The value NULL hasn't been around as long as unset.
And there were minor releases where I THINK it went a bit funky about
whether you'd have that key in the array, for some weird situations...
unset has been around and has worked the same for a lonnnnnnng time.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?