What are some strategies for avoiding decreasing values within nested loops in PHP?

When working with nested loops in PHP, it's important to be mindful of any potential changes to variables that could affect the behavior of the loops. To avoid decreasing values within nested loops, you can store the initial value of the variable in a separate variable before entering the nested loop. This way, the original value is preserved and can be used as needed within the nested loop without being altered.

// Example of avoiding decreasing values within nested loops
$outerLimit = 5;

for ($i = 1; $i <= $outerLimit; $i++) {
    $innerLimit = $outerLimit; // Store the initial value of $outerLimit

    for ($j = 1; $j <= $innerLimit; $j++) {
        // Nested loop logic here
    }
}