<?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);
&$item writes back into the array