[Solved] php make multidimensional array with values to keys [closed]


Strangely worded but still a valid question (in my opinion), so I really don’t get the downvotes. Anyway, here’s one possible solution:

function foo($content, $keys) {
  return sizeof($keys) === 0 ? $content : foo([array_pop($keys) => $content], $keys);
}

print_r(foo('bar', ['a', 'b', 'c', 'd', 'e']));

demo: http://3v4l.org/2tcJ5

1

solved php make multidimensional array with values to keys [closed]