I have an array
$animals['dogs']['lassie']['legs'] = 4
Given the variables
$path = "['dogs']['lassie']['legs']";
$value = 3;
How do I update the $animals array so that
$animals['dogs']['lassie']['legs'] = 3;
My best guess of
$arr = 'animals'.$path;
${$arr} = $value;
didn't work.
I have read that it can be done using eval() but also that it shouldn't be done using eval()!
Any help is gratefully received.