Re: delete part of array
| From: | John Nichel | Date: | Thu, 13 Jan 2005 21:22:22 +0000 |
| Subject: | Re: delete part of array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206323@lists.php.net to get a copy of this message | ||
Ford, Mike wrote:
<snip>
Without actually running it (I'm too lazy!), I'm pretty sure this won't work correctly -- the count($array) is being recalculated each time round the loop, so each time you do an unset() it will reduce by one, resulting in the last few elements never being checked. </snip>Not too much on this topic, but to save youself a few cpu cycles, you could put your size outside of the for loop $size = sizeof ( $array ); for ( $i = 0; $i < $size; $i++ ) Putting it inside the for() makes it call that function on every loop. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 john@kegworks.com