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 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 32
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 32
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 9
Branch analysis from position: 20
Branch analysis from position: 9
filename:       /in/cfWTn
function name:  (null)
number of ops:  37
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        FETCH_CONSTANT                                   ~14     'n'
          6        MUL                                              ~15     ~14, 2
          7        ASSIGN                                                   !5, ~15
          8      > JMP                                                      ->18
    9     9    >   ASSIGN_DIM                                               !2, !4
         10        OP_DATA                                                  !4
   10    11        FETCH_CONSTANT                                   ~18     'i'
         12        SUB                                              ~19     !5, ~18
         13        ASSIGN_DIM                                               !2, ~19
         14        OP_DATA                                                  !4
   11    15        ASSIGN_DIM                                               !3
         16        OP_DATA                                                  <array>
    8    17        PRE_INC                                                  !4
         18    >   IS_SMALLER_OR_EQUAL                                      !4, !1
         19      > JMPNZ                                                    ~23, ->9
   15    20    > > FE_RESET_R                                       $24     !0, ->32
         21    > > FE_FETCH_R                                       ~25     $24, !6, ->32
         22    >   ASSIGN                                                   !4, ~25
   16    23        MOD                                              ~27     !4, !5
         24        ASSIGN                                                   !7, ~27
   17    25        FETCH_DIM_R                                      ~29     !2, !7
         26        SUB                                              ~30     ~29, 1
         27        ASSIGN                                                   !8, ~30
   18    28        FETCH_DIM_W                                      $32     !3, !8
         29        ASSIGN_DIM                                               $32
         30        OP_DATA                                                  !6
   15    31      > JMP                                                      ->21
         32    >   FE_FREE                                                  $24
   21    33        INIT_FCALL                                               'print_r'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.5 ms | 1405 KiB | 15 Q