RE: [PHP] removing an element from an array
| From: | Ford, Mike [LSS] | Date: | Wed, 01 Oct 2003 10:58:29 +0000 |
| Subject: | RE: [PHP] removing an element from an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-164519@lists.php.net to get a copy of this message | ||
On 01 October 2003 11:25, Angelo Zanetti contributed these pearls of wisdom:
> Hi
>
> If I have an array and want to remove and element from this
> array. correct me if this is the wrong approach:
It's the wrong approach ;)
> create a temporary array with 1 element less than the
> origional array, get the position of the element ( is there a
> function for this?) and then run through the origional array
> copying all elements besides the element which is meant to be
> removed.
>
> Is there no function to do this? It seems like alot of
> overhead to do this process, especially if the array is big.
> comments?
unset($array[$key]);
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211