Here is the array itself:

0 => [ 0 => int 904 1 => int 928 2 => int 937], 1 => [ 0 => int 351 1 => int 352 2 => int 353], 2 => [ 0 => int 903 1 => int 972 2 => int 974] 

I need to get this:

 [0 => int 904 1 => int 928 2 => int 937 3 => int 351 4 => int 352 5 => int 353 6 => int 903 7 => int 972 8 => int 974] 

Can this be done somehow without foreach ?

  • What to do with doubles, if they will meet? - Alexey Shimansky
  • @ AlekseyShimansky will not be duplicated - Sergalas

1 answer 1

Use the array_reduce function, Luke!
Like that:

 $fArr = [[904,928,937], [351,352,353], [903,972,974]]; var_dump(array_reduce($fArr, function($acc, $item){return array_merge($acc, $item);}, [])); 

https://repl.it/EIF4/0

  • The same forich turned out) - Naumov
  • @Naumov, brute force will be in any case, but there is a difference between brute force on the compiled function and brute force banging with its construction. - user207618