Spot the bug in the foreach reference

from Arrays
PHP 8.3.33 intermediate 4 min 1 issue to find

Find why the final array contains 1300 twice.

php
<?php
function discountedPrices(array $prices): array
{
    foreach ($prices as &$price) {
        $price -= 500;
    }

    foreach ($prices as $price) {
        // A later read-only loop should not change the array.
    }
    return $prices;
}
Open in playground
Report an error