This one should be easy. I am trying to determine if calculating the length of the loop in advance is faster then counting inside a for loop.
If we code straight, we should always avoid doing something big inside a for loop or any other kind of loop. For example, it is always better to write a more complex SQL query and get all that we need to show to the user before the loop and avoid making n SQL queries inside a loop.
Consider this two code snippets:
$a = array_fill(5, 1000, ‘test’);