Re: delete part of array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux