Organizational Research By

Surprising Reserch Topic

dynamic array keys using -'php,arrays,multidimensional-array'

dynamic array keys  using -'php,arrays,multidimensional-array'

I have a string like this:

$string = 'one/two/three/four';

which I turn it into a array:

$keys = explode('/', $string);

This array can have any number of elements, like 1, 2, 5 etc.

How can I assign a certain value to a multidimensional array, but use the $keys I created above to identify the position where to insert?


$arr['one']['two']['three']['four'] = 'value';

Sorry if the question is confusing, but I don't know how to explain it better

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.