Dave's Brain

Browse - programming tips - php delete array element

Date: 2007nov19

Q.  How do I delete an element from a PHP array?

A.  You can unset($a[$element]) but that leaves a hole so the only way is
to copy the array to a new one without the unwanted element.

I think this is an unfortunate limitation for a high level language.
Even C++'s vector can erase() elements.

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.