> -----Original Message----- > From: Daevid Vincent [mailto:daevid@;daevid.com] > Sent: 08 November 2002 11:13 > > 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?
With bare PHP, yes the first one is quicker. Don't know if the Zend Optimiser changes that. 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: [EMAIL PROTECTED] 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