What are some common pitfalls when using nested loops in PHP?

One common pitfall when using nested loops in PHP is accidentally creating an infinite loop. This can happen if the conditions for exiting the inner loop are not properly defined or if the loop counter is not being updated correctly. To avoid this issue, always make sure to have a clear exit condition for each loop and update loop counters accordingly.

// Example of nested loops with proper exit conditions

for ($i = 0; $i < 5; $i++) {
    for ($j = 0; $j < 3; $j++) {
        echo "i: $i, j: $j\n";
    }
}