-1

Is it possible to do this in PHP:

$a['foo'] = [1,2,3];
$a['bar'] = [4,5,6];

Instead of array_merge($a['foo'], $a['bar']), you would use simply use something like array_merge($a) instead?

IMB
  • 15,163
  • 19
  • 82
  • 140

1 Answers1

1

Live demo

function my_array_merge($array) {
   $result = [];
   foreach($array as $subArray) {
      $result = array_merge($result, $subArray);
   }
   return $result;
} 
CMPS
  • 7,733
  • 4
  • 28
  • 53