Tarasovych

Untitled

Sep 20th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. $input = [ [1,2,3], [4,5,6], [7,8,9] ];
  2.  
  3. for ($i = 0; $i < count($input); $i++) {
  4.  
  5. $res[] = [
  6.     array_shift($input[0]),
  7.     array_shift($input[1]),
  8.     array_shift($input[2])
  9.                 ];
  10. }
  11.  
  12. //output
  13. Array
  14. (
  15.     [0] => Array
  16.         (
  17.             [0] => 1
  18.             [1] => 4
  19.             [2] => 7
  20.         )
  21.  
  22.     [1] => Array
  23.         (
  24.             [0] => 2
  25.             [1] => 5
  26.             [2] => 8
  27.         )
  28.  
  29.     [2] => Array
  30.         (
  31.             [0] => 3
  32.             [1] => 6
  33.             [2] => 9
  34.         )
  35.  
  36. )
Advertisement
Add Comment
Please, Sign In to add comment