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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.37 ms | 1400 KiB | 15 Q