Dynamically Set Deep Dictionary Values
If you have ever needed to set some values of a dictionary in JavaScript or PHP, then you know that you have to do something like myArray[a][b][c] = 0
. But what if we don’t know that the subkeys will be “a->b->c” until runtime? You would need a way to index into the dictionary dynamically and return the resulting modified dictionary. Below are code snippets in JavaScript and PHP that do exactly that.