3v4l.org

run code in 500+ PHP versions simultaneously
<?php function custom_chunk($array, $maxrows) { $size = sizeof($array); $columns = ceil($size / $maxrows); $fullrows = $size - ($columns - 1) * $maxrows; for ($i = 0; $i < $maxrows; ++$i) { $result[] = array_splice($array, 0, ($i < $fullrows ? $columns : $columns - 1)); } return $result; } var_export(custom_chunk(range('a', 'r'), 12));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/80YaE
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                                   'var_export'
          1        INIT_FCALL                                                   'custom_chunk'
          2        INIT_FCALL                                                   'range'
          3        SEND_VAL                                                     'a'
          4        SEND_VAL                                                     'r'
          5        DO_ICALL                                             $0      
          6        SEND_VAR                                                     $0
          7        SEND_VAL                                                     12
          8        DO_FCALL                                          0  $1      
          9        SEND_VAR                                                     $1
         10        DO_ICALL                                                     
         11      > RETURN                                                       1

Function custom_chunk:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
Branch analysis from position: 15
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 15
Branch analysis from position: 31
Branch analysis from position: 15
filename:       /in/80YaE
function name:  custom_chunk
number of ops:  33
compiled vars:  !0 = $array, !1 = $maxrows, !2 = $size, !3 = $columns, !4 = $fullrows, !5 = $i, !6 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    3     2        COUNT                                                ~7      !0
          3        ASSIGN                                                       !2, ~7
    4     4        INIT_FCALL                                                   'ceil'
          5        DIV                                                  ~9      !2, !1
          6        SEND_VAL                                                     ~9
          7        DO_ICALL                                             $10     
          8        ASSIGN                                                       !3, $10
    5     9        SUB                                                  ~12     !3, 1
         10        MUL                                                  ~13     !1, ~12
         11        SUB                                                  ~14     !2, ~13
         12        ASSIGN                                                       !4, ~14
    7    13        ASSIGN                                                       !5, 0
         14      > JMP                                                          ->29
    8    15    >   INIT_FCALL                                                   'array_splice'
         16        SEND_REF                                                     !0
         17        SEND_VAL                                                     0
         18        IS_SMALLER                                                   !5, !4
         19      > JMPZ                                                         ~18, ->22
         20    >   QM_ASSIGN                                            ~19     !3
         21      > JMP                                                          ->24
         22    >   SUB                                                  ~20     !3, 1
         23        QM_ASSIGN                                            ~19     ~20
         24    >   SEND_VAL                                                     ~19
         25        DO_ICALL                                             $21     
         26        ASSIGN_DIM                                                   !6
         27        OP_DATA                                                      $21
    7    28        PRE_INC                                                      !5
         29    >   IS_SMALLER                                                   !5, !1
         30      > JMPNZ                                                        ~23, ->15
   10    31    > > RETURN                                                       !6
   11    32*     > RETURN                                                       null

End of function custom_chunk

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.27 ms | 3406 KiB | 18 Q