RE: [PHP] Re: removing an element from an array

From: Date: Wed, 01 Oct 2003 11:44:17 +0000
Subject: RE: [PHP] Re: removing an element from an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-164535@lists.php.net to get a copy of this message
how do I find the position of the element in the array? based on the value that is passed? if there a funtion for this or do I manually have to get this value? -----Original Message----- From: Dennis Sterzenbach [mailto:lists@darknoise.de] Sent: Wednesday, October 01, 2003 1:16 PM To: php-general@lists.php.net Subject: [PHP] Re: removing an element from an array > Is there no function to do this? It seems like alot of overhead to do this > process, especially if the array is big. comments? > Not if you do not create another array, which in my oppinion is totally unnecessary. I always did the following after finding the position from where to strip off the element: for ($i=$elpos; $i<count($array); $i++) { $array[$i] = $array[$i+1]; } unset($array[count($array)-1]); -- Dennis Sterzenbach www.darknoise.de -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#164535) next »