I have some more PHP Performance notes somewhere, but this is all that I can find right now.
- Use for loops over foreach loops
- Use ‘ over “, unless you are parsing variables
- Use echo over print
For Loops
Use either of the following syntax for your for loops. They take about the same amount of time to execute
$count = count($arr); for ($i = 0; $i < $count; $i++) { } for ($i = 0, $count = count($arr); $i < $count; $i++) { }
DO NOT use the following, it is significantly slower:
for ($i = 0; $i < $count($arr); $i++) { }