Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Speed up Performance of Loop with Large Arrays

As we know, FOR loop is same for all programming language, it does not matter , in which language you are working. This is about how to decrease load time. I have shown an example of PHP language. Generallly we are using the FOR loop as below which count a $large_array every time the FOR loop execute.

<?php for($i=0;$i<count($large_array);$i++)
{
//Whatever you want goes here
}

?>

Now look at the below FOR Loop which gives output with faster execution as it will count $large_array only once during initilization. As a result,you will get speed up in your application which makes your application more efficient.

<?php

for($i=0,$cnt=count($large_array); $i<$cnt; $i++)
{
//Whatever you want goes here
}

?>

Look at below links for great magic tricks.

To know more about programming ,MYSQL database , php info , php editor , programming php ,Open-source, php help and php script , subscribe to our feed by entering email address below. You will get updates via email about every tutorial posted on this site . It will not take more than a sec.

Enter your email address:
 
Feel free to ask any question. Just leave your comment below and we will answer your comment with in 24 hours.
Share:

7 Comments

Leave a Reply

Your email address will not be published.