Get Array value by string of keys
- by Esben Petersen
Hello,
i'm building a template engine for my next project, which is going great. It replaces {tag} with a corresponding value. But, i want {tag[0][key]} to be replaced as well. All i need to know is how to get the value, if i have the string representation of the array and key, like this:
$arr = array(
0=>array(
'key'=>'value'
),
1=>array(
'key'=>'value2'
)
);
$tag = 'arr[0][key]';
echo($$tag);
This is a very simple version of the problem, i hope you understand it. Or else i would be happy to anwser any questions about it :)
Thanks for any help in advantage