ecometer

Do not call a function in the declaration of a for loop

(Development)
#50

Do not call a function in the declaration of a for loop to avoid the function being called each time the loop is iterated.

Instead of:

for ($i = 0; $i < count($array); $i++) {}

write:

$count = count($array);
for ($i = 0; $i < $count; $i++) {}
This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license