$myArray[]=$big_number in your loop). So if you know it is not going to change, use the first way.
Daevid Vincent wrote:
Is PHP smart enough to optimize loops?
That is, are these two 'for...loops' equivalent or is one slower than
the other?
$max = max($myArray);
for( $x = 1; $x <= $length; $x++ ) {}
-- OR --
for( $x = 1; $x <= max($myArray); $x++ ) {}
My gut instinct tells me since PHP is interpreted, that the top one is
the better way to go, but with the Zend Optimizer, I don't know if PHP
handles them the same way or not?
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php