3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_export( array2cols(range('a', 'r'), 12) ); function array2cols($array,$n){ $groups = array(); for($i=0;$i<$n;$i++){ $groups[$i] = array(); } $col = 0; foreach($array as $row){ $groups[$col][] = $row; $col = ($col+1)%$n; } return $groups; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Vn3UM
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'var_export'
    4     1        INIT_FCALL_BY_NAME                                       'array2cols'
          2        INIT_FCALL                                               'range'
          3        SEND_VAL                                                 'a'
          4        SEND_VAL                                                 'r'
          5        DO_ICALL                                         $0      
          6        SEND_VAR_NO_REF_EX                                       $0
          7        SEND_VAL_EX                                              12
          8        DO_FCALL                                      0  $1      
          9        SEND_VAR                                                 $1
         10        DO_ICALL                                                 
   18    11      > RETURN                                                   1

Function array2cols:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 5
Branch analysis from position: 10
Branch analysis from position: 5
filename:       /in/Vn3UM
function name:  array2cols
number of ops:  23
compiled vars:  !0 = $array, !1 = $n, !2 = $groups, !3 = $i, !4 = $col, !5 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN                                                   !2, <array>
    9     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->8
   10     5    >   ASSIGN_DIM                                               !2, !3
          6        OP_DATA                                                  <array>
    9     7        PRE_INC                                                  !3
          8    >   IS_SMALLER                                               !3, !1
          9      > JMPNZ                                                    ~10, ->5
   12    10    >   ASSIGN                                                   !4, 0
   13    11      > FE_RESET_R                                       $12     !0, ->20
         12    > > FE_FETCH_R                                               $12, !5, ->20
   14    13    >   FETCH_DIM_W                                      $13     !2, !4
         14        ASSIGN_DIM                                               $13
         15        OP_DATA                                                  !5
   15    16        ADD                                              ~15     !4, 1
         17        MOD                                              ~16     ~15, !1
         18        ASSIGN                                                   !4, ~16
   13    19      > JMP                                                      ->12
         20    >   FE_FREE                                                  $12
   17    21      > RETURN                                                   !2
   18    22*     > RETURN                                                   null

End of function array2cols

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.23 ms | 1404 KiB | 17 Q