The following works...
$a = ['a','b','c'=>[1,2,3]];
$b = &$a;
$b = &$b['c'];
So... I want to change the reference of an array with this function:
function change_array_pointer ( &$array, $path ) {
foreach ($path as $subpath) {
$array = &$array[$subpath];
}
}
Looks simple, but doesn't work.
For example, this code is not working and I don't know why:
$a = ['a','b','c'=>[1,2,3]];
$b = &$a;
change_array_pointer($b,['c']);
In my opinion $b should be [1,2,3], but it's not.
Please explain to me what's happening :(