What are some common pitfalls to avoid when working with for loops in PHP?

One common pitfall to avoid when working with for loops in PHP is off-by-one errors, where the loop either runs one too many times or one too few times. To prevent this, ensure your loop conditions are correctly set to start and end at the appropriate values.

// Example of avoiding off-by-one errors in a for loop
for ($i = 0; $i < 5; $i++) {
    // Loop code here
}