What potential issues can arise from overwriting variables within a foreach loop in PHP?

Overwriting variables within a foreach loop can lead to unexpected behavior and errors in your code. To avoid this issue, you can use a different variable name within the loop to store the current item being iterated over.

$items = [1, 2, 3, 4, 5];

foreach ($items as $item) {
    $currentItem = $item;
    // Do something with $currentItem
}