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.






I am
about 2 years ago
Using count in the arguments of the for loop isn’t recommended..
$cnt = count($large_array);
for($i = 0; $i < $cnt; ++$i){…}
about 2 years ago
Using count in the arguments of the for loop isn’t recommended..
$cnt = count($large_array);
for($i = 0; $i < $cnt; ++$i){…}
about 2 years ago
@EllisGL — thanks for sharing knowledge.
about 2 years ago
@EllisGL — thanks for sharing knowledge.
about 2 years ago
this topic is useful in faster execution of program
good activities
about 2 years ago
this topic is useful in faster execution of program
good activities