xxxxxxxxxx
function set_val(array &$arr, $path,$val)
{
$loc = &$arr;
foreach(explode('.', $path) as $step)
{
$loc = &$loc[$step];
}
return $loc = $val;
}
xxxxxxxxxx
Dot notation works fine unless we stump upon few special cases such as
• If the variable contains a dot(.), colon(:), starting
or ending with an underscore or any known public attribute.
• If there’s a collision between methods and attributes of python dictionaries.
• Array notation also allows for dynamic variable composition.