I have an input array, with path like
var path = ["foo","bar","baz"];
And I have an object
var obj = {
    "foo": {
         "bar": {
              "baz": "cake"
         },
         "notbar": {
              "another": "value"
         }
    }
}
And i want to change the "baz" value from the path. I know i can use
obj[path[0]][path[1]][path[2]] = "value";
but i dont know how long the array will be. both php and javascript anwsers are appreciated!
 
     
    