RE: [PHP] removing an element from an array
| From: | Angelo Zanetti | Date: | Wed, 01 Oct 2003 11:09:09 +0000 |
| Subject: | RE: [PHP] removing an element from an array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164521@lists.php.net to get a copy of this message | ||
isnt the unset function not a safe function to use & was discontinued, i
think thats why its not in the manual.
-----Original Message-----
From: Ford, Mike [LSS] [mailto:M.Ford@lmu.ac.uk]
Sent: Wednesday, October 01, 2003 12:58 PM
To: 'angelo@zlogic.co.za'; Php-General@Lists.Php.Net
Subject: RE: [PHP] removing an element from an array
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php