Optimising “For” Loops [TotD]

Posted by hts | December 30, 2007 .

From now on, I’ll (try to) post, every day, a quick tip, usually regarding PHP programming. (TOTD= tip of the day)
So for today, I’ll show you how to optimise your application speed with a simple trick regarding FOR loops in PHP:
Problem
Lets take the following example:

<?php//let’s suppose $max and $min variables are pulled from a databasefor ($i=1;$i< ($max-$min);$i++) {      //do something}?>

This is inefficient, unoptimised, memory and CPU consuming, etc - you […]

« Previous Page