Another loop speed tip
Consider this first loop:
$x * $factor is repeated 50 unnecessary times per iteration.PHP Code:
$total = 0;
$factor = 100;
for($x = 0; $x < 50; $x++) {
for($y = 0; $y < 50; $y++) {
$total += ($x * $y) + ($x * $factor) + ($y * $factor);
}
}
PHP Code:
$total = 0;
$factor = 100;
for($x = 0; $x < 50; $x++) {
$xfactor = $x * $factor;
for($y = 0; $y < 50; $y++) {
$total += ($x * $y) + $xfactor + ($y * $factor);
}
}