0

I have array like this:

['firstTest' => ['secondTest' => 'x', 'thirdTest' => 'y'], 'fourthTest => 'z'];

I would like to create array like this:

['firstTest.secondTest' => 'x', 'firstTest.thirdTest' => 'y', 'fourthTest' => 'z']

I need to do it with PHP.

My array is also nested with 5-10 times.

Tebby
  • 1
  • 1
  • Found the dupe with 2 seconds of Google search. You might have to make some small tweaks but the essence remains the same. – nice_dev Aug 19 '22 at 12:12
  • This solution may also work. https://stackoverflow.com/questions/1319903/how-to-flatten-a-multidimensional-array – O. Jones Aug 19 '22 at 12:15
  • Thanks. I found it, but my array is more nested, so this solution doesn't work. – Tebby Aug 19 '22 at 12:17
  • It works fine for the example you have given in the question. If you have a more complex situation - then show a proper example of that. – CBroe Aug 19 '22 at 12:44

0 Answers0