What is the potential issue with using the range() function within nested loops in PHP?

When using the range() function within nested loops in PHP, the potential issue is that the inner loop will reset the pointer of the array generated by the range() function, causing unexpected behavior. To solve this issue, you can store the range array in a separate variable before entering the nested loop and then use that variable within the loop.

// Storing the range array in a separate variable before entering the nested loop
$numbers = range(1, 10);

foreach ($numbers as $number) {
    // Nested loop
    foreach ($numbers as $innerNumber) {
        echo $number * $innerNumber . " ";
    }
    echo "\n";
}