This is probably going to sound strange, but I like to try to think outside the
box (buzzphrase!) and hit things at odd angles.
Would someone care to test (or already know) the performance difference between
a "for" loop and a "foreach" loop?
Or the performance difference over many iterations o
Hi,
I imagine this kind of thing is not especially taxing on the processor,
especially if the condition is a fairly simple comparison. That said, I
have very little understanding aside from my own limited experience of
what runs slowly!
If you're worried about code maintenance, then move the cod
Hi,
David is right about the unwanted side-effect. Thanks for the idea though.
Unfortunately the 'greater problem' is not so great, I've just been doing
this for a while now and find myself programming loops like these so often
and I've never got round to testing if a simple IF statement is a maj
Jared Williams wrote:
> Why not
>
> for ($i = 0; $i < 100/100; ++$i)
This involves dividing 100 by 100 for each iteration of the loop.
It would be better to test against 1.
There is also the unwanted side-effect of executing the code on each
hundredth iteration, which is unwanted (as
ecember 2005 10:18
> To: php-general@lists.php.net
> Subject: [PHP] Unnecessary if statement? Programming technique
>
> Hi everyone
>
> Quick question:
>
> If I have such a loop:
>
> for($i=0;$i<100;$i++) {
> if($i==100) {
>
> }
> // do
Hi everyone
Quick question:
If I have such a loop:
In this case it seems such a waste that the if() statement is done 99
times when it's not needed. Is there any obvious trick that I am missing?
I'm not sure how taxing a simple if() statement is on a server, maybe it's
negligible, or is
6 matches
Mail list logo