Values & References5 / 16
Up next

foreach by reference

<?php
declare(strict_types=1);
$nums = [1, 2, 3];
// & lets the loop modify each element in place
foreach ($nums as &$n) {
    $n *= 10;
}
// break the reference when done
unset($n);
print_r($nums);
What you're solving

&$item writes back into the array