Search code examples
phparraysunwarp

how to unwrap an array in php


i have this array here:

Array
(
 [0] => Array
     (
         [presentation] => Präsentationen
     )

 [1] => Array
     (
         [news] => Aktuelle Meldungen
         [devplan] => Förderprogramme
         [salesdoc] => Vertriebsunterlagen
     )

 [2] => Array
     (
         [user/settings] => Mein Account
     )

 [3] => Array
     (
     )

 [4] => Array
     (
         [orders] => Projekte
     )

)

i want to unwrap the first depth of the array to get this:

 Array
 (
  [presentation] => Präsentationen
  [news] => Aktuelle Meldungen
  [devplan] => Förderprogramme
  [salesdoc] => Vertriebsunterlagen
  [user/settings] => Mein Account
  [orders] => Projekte
 )

Solution

  • With PHP 5.3.0+:

    array_reduce($array, 'array_merge', array());