3v4l.org

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

Function double_chunk:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k9e6Y
function name:  double_chunk
number of ops:  41
compiled vars:  !0 = $array, !1 = $maxrows, !2 = $size, !3 = $columns, !4 = $fullrows
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    3     2        COUNT                                                ~5      !0
          3        ASSIGN                                                       !2, ~5
    4     4        INIT_FCALL                                                   'ceil'
          5        DIV                                                  ~7      !2, !1
          6        SEND_VAL                                                     ~7
          7        DO_ICALL                                             $8      
          8        ASSIGN                                                       !3, $8
    5     9        SUB                                                  ~10     !3, 1
         10        MUL                                                  ~11     !1, ~10
         11        SUB                                                  ~12     !2, ~11
         12        ASSIGN                                                       !4, ~12
    7    13        IS_EQUAL                                                     !4, !1
         14      > JMPZ                                                         ~14, ->20
    8    15    >   INIT_FCALL                                                   'array_chunk'
         16        SEND_VAR                                                     !0
         17        SEND_VAR                                                     !4
         18        DO_ICALL                                             $15     
         19      > RETURN                                                       $15
   10    20    >   INIT_FCALL                                                   'array_merge'
   11    21        INIT_FCALL                                                   'array_chunk'
   12    22        INIT_FCALL                                                   'array_splice'
         23        SEND_REF                                                     !0
         24        SEND_VAL                                                     0
         25        MUL                                                  ~16     !3, !4
         26        SEND_VAL                                                     ~16
         27        DO_ICALL                                             $17     
         28        SEND_VAR                                                     $17
   13    29        SEND_VAR                                                     !3
   11    30        DO_ICALL                                             $18     
   13    31        SEND_VAR                                                     $18
   15    32        INIT_FCALL                                                   'array_chunk'
         33        SEND_VAR                                                     !0
         34        SUB                                                  ~19     !3, 1
         35        SEND_VAL                                                     ~19
         36        DO_ICALL                                             $20     
         37        SEND_VAR                                                     $20
   10    38        DO_ICALL                                             $21     
   15    39      > RETURN                                                       $21
   17    40*     > RETURN                                                       null

End of function double_chunk

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
174.98 ms | 2725 KiB | 20 Q