What is the potential issue with having a foreach loop inside a for loop in PHP?

Having a foreach loop inside a for loop in PHP can lead to unexpected behavior or errors because the foreach loop will reset the internal array pointer of the array it is iterating over. To avoid this issue, you can create a copy of the array before the for loop and then iterate over the copy using the foreach loop.

$originalArray = [1, 2, 3, 4, 5];
$arrayCopy = $originalArray;

for ($i = 0; $i < count($arrayCopy); $i++) {
    foreach ($arrayCopy as $value) {
        // Your code here
    }
}