Re: for/foreach speed
| From: | Robert Cummings | Date: | Mon, 20 Aug 2007 17:21:59 +0000 |
| Subject: | Re: for/foreach speed | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261055@lists.php.net to get a copy of this message | ||
On Mon, 2007-08-20 at 18:50 +0200, Sascha Braun, CEO @ fit-o-matic
wrote:
> Hi people,
>
> could somebody please explain me, what loop construct is
> faster? The for, while or foreach.
I haven't bothered testing but I'd wager $5 that the following is the
fastest loop:
<?php
while( 1 )
{
}
?>
Depending on bytecode creation though, the following might be just as
fast:
<?php
for( ;; )
{
}
?>
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................