Are arrays in PHP passed by value or by reference? and other answers describe how in PHP one can pass a variable by reference into a function and modify it inside the function.
But I'd like to pass a variable by reference into a function and modify it =after= (outside of) the function call. I've tried to do something like this several times in my PHP life but it doesn't work.
Example:
$arr=['a'=>['b'=>'B']]; // An array inside an array
$inside=[];
GetInsideArray($arr,$inside);
$inside['b']='C';
... (other similar modifications omitted)
// At this point, $inside['b'] is 'C' but $arr['a']['b'] is still 'B'
function GetInsideArray($arr,&$inside)
{
$inside=$arr['a'];
} // GetInsideArray
Is there a simple way to get this to work?