<?php
# similar to $source array, but implemented using a function
function getSource() {
return [ 'subarray' => ['item' => 'old value ---'] ];
}
# $ref3 is assigned to result of getSource() right in the foreach()
foreach ( $ref3 = getSource() as &$subarray ) {
$subarray['item'] = 'NEW value';
echo $subarray['item'], PHP_EOL;
echo $ref3['subarray']['item'], PHP_EOL;
}
echo PHP_EOL;