Reputation: 3465
i wanted to covert array values into a multidimensional associative array. Array size can be dynamic.
Array to be converted:
Array
(
[0] => abc
[1] => 0
[2] => xyz
[3] => 0
)
Expected Output:
Array
(
[abc] => Array
(
[0] => Array
(
[xyz] => Array
(
[0] =>
)
)
)
)
Tried with popping first key, but that has no luck...
Upvotes: 1
Views: 86
Reputation: 453
Try this..
$tmpArr = array('Abc', '0', 'ABC','0'); $array = array(); foreach (array_reverse($tmpArr) as $arr) $array = array($arr => $array);
Upvotes: 4