3v4l.org

run code in 300+ PHP versions simultaneously
<?php $master_array = array(1, 2, 3, 4, 5, 6); $n = 2; // This is the number of columns / arrays $pattern_array = array(); $meta_array = array(); for ($i=1, $z=2*$n; $i <= $n; ++$i) { $pattern_array[$i] = $i; $pattern_array[$z-$i] = $i; $meta_array[] = array(); } foreach ($master_array as $i => $element) { $pattern_index = $i % $z; $meta_index = $pattern_array[$pattern_index] - 1; $meta_array[$meta_index][] = $element; } print_r($meta_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 8
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 30
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 30
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 8
Branch analysis from position: 18
Branch analysis from position: 8
filename:       /in/88jhN
function name:  (null)
number of ops:  35
compiled vars:  !0 = $master_array, !1 = $n, !2 = $pattern_array, !3 = $meta_array, !4 = $i, !5 = $z, !6 = $element, !7 = $pattern_index, !8 = $meta_index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 2
    6     2        ASSIGN                                                   !2, <array>
    7     3        ASSIGN                                                   !3, <array>
    8     4        ASSIGN                                                   !4, 1
          5        MUL                                              ~14     !1, 2
          6        ASSIGN                                                   !5, ~14
          7      > JMP                                                      ->16
    9     8    >   ASSIGN_DIM                                               !2, !4
          9        OP_DATA                                                  !4
   10    10        SUB                                              ~17     !5, !4
         11        ASSIGN_DIM                                               !2, ~17
         12        OP_DATA                                                  !4
   11    13        ASSIGN_DIM                                               !3
         14        OP_DATA                                                  <array>
    8    15        PRE_INC                                                  !4
         16    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         17      > JMPNZ                                                    ~21, ->8
   15    18    > > FE_RESET_R                                       $22     !0, ->30
         19    > > FE_FETCH_R                                       ~23     $22, !6, ->30
         20    >   ASSIGN                                                   !4, ~23
   16    21        MOD                                              ~25     !4, !5
         22        ASSIGN                                                   !7, ~25
   17    23        FETCH_DIM_R                                      ~27     !2, !7
         24        SUB                                              ~28     ~27, 1
         25        ASSIGN                                                   !8, ~28
   18    26        FETCH_DIM_W                                      $30     !3, !8
         27        ASSIGN_DIM                                               $30
         28        OP_DATA                                                  !6
   15    29      > JMP                                                      ->19
         30    >   FE_FREE                                                  $22
   21    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.48 ms | 1401 KiB | 15 Q