0

If I have an array, with a single array inside it. Is there a way push the child array values into the parent without having to run a foreach?

For example, if I have an array like this:

array( [0] => array(
               "key1" => "value1",
               "key2" => "value2",
                "key3" => "value3",
               )
     );

and I want to reduce it to this:

  array(
    "key1" => "value1",
    "key2" => "value2",
    "key3" => "value3",
   );

Is there a way of doing this without a foreach?

at the moment I'm doing this:

$singleArr = array();
foreach($multiArr as $subArr) {
   $singleArr = $subArr;
}
user3143218
  • 1,568
  • 3
  • 28
  • 44
  • This was asked again a couple minutes ago: http://stackoverflow.com/questions/24821550/transformation-multidimensional-array-into-single-array – Jon Jul 18 '14 at 09:30

1 Answers1

1

What about simple:

$singleArr = $multiArr[0];
hsz
  • 143,040
  • 58
  • 252
  • 308
  • I'll accept when I can. BTW i think this is a good question for a lot people, although easily solved, I imagine it's quite common – user3143218 Jul 18 '14 at 09:32