Say I have a function called set_session_variable that looks like:
function set_session_variable($name, $value) {
// ...write value to the specified path
}
How would I write this function (without using an eval) so that I can do something like:
set_session_variable('foo', 'bar'); // Would set $_SESSION['foo'] = 'bar';
set_session_variable('foo[bar][baz]', 'blah'); // Would set $_SESSION['foo']['bar']['baz'] = 'blah';
foois a string. Next you setfoo[bar][baz]to blah. What behaviour do you expect at this point? Do you want to convertfoofrom string to array (such thatfoo[bar][blaz]has value blah)? Or $_SESSION['foo'] gives you array such that $_SESSION['foo']['bar']['baz'] == 'blah?