RE: [PHP] For ... <= max($myArray) vs For ... <= $max

From: Date: Fri, 08 Nov 2002 12:10:40 +0000
Subject: RE: [PHP] For ... <= max($myArray) vs For ... <= $max
Groups: php.general 
Request: Send a blank email to php-general+get-123356@lists.php.net to get a copy of this message
> -----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: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#123356) next »