3v4l.org

run code in 300+ PHP versions simultaneously
<?php function special_chunk($array, $size) { $chunks = array_chunk($array, 2); $count = count($chunks); if( count($chunks[$count-1]) < $size ) { $chunks[$count-2] = array_merge($chunks[$count-2], $chunks[$count-1]); unset($chunks[$count-1]); } return $chunks; } $languages = range(1, 8); var_dump( special_chunk($languages, 3) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p776r
function name:  (null)
number of ops:  13
compiled vars:  !0 = $languages
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 8
          3        DO_ICALL                                         $1      
          4        ASSIGN                                                   !0, $1
   16     5        INIT_FCALL                                               'var_dump'
   17     6        INIT_FCALL                                               'special_chunk'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 3
          9        DO_FCALL                                      0  $3      
         10        SEND_VAR                                                 $3
   16    11        DO_ICALL                                                 
   18    12      > RETURN                                                   1

Function special_chunk:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 27
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/p776r
function name:  special_chunk
number of ops:  29
compiled vars:  !0 = $array, !1 = $size, !2 = $chunks, !3 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_chunk'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 2
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
    5     7        COUNT                                            ~6      !2
          8        ASSIGN                                                   !3, ~6
    7     9        SUB                                              ~8      !3, 1
         10        FETCH_DIM_R                                      ~9      !2, ~8
         11        COUNT                                            ~10     ~9
         12        IS_SMALLER                                               ~10, !1
         13      > JMPZ                                                     ~11, ->27
    8    14    >   SUB                                              ~12     !3, 2
         15        INIT_FCALL                                               'array_merge'
         16        SUB                                              ~14     !3, 2
         17        FETCH_DIM_R                                      ~15     !2, ~14
         18        SEND_VAL                                                 ~15
         19        SUB                                              ~16     !3, 1
         20        FETCH_DIM_R                                      ~17     !2, ~16
         21        SEND_VAL                                                 ~17
         22        DO_ICALL                                         $18     
         23        ASSIGN_DIM                                               !2, ~12
         24        OP_DATA                                                  $18
    9    25        SUB                                              ~19     !3, 1
         26        UNSET_DIM                                                !2, ~19
   11    27    > > RETURN                                                   !2
   12    28*     > RETURN                                                   null

End of function special_chunk

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
123.39 ms | 1008 KiB | 18 Q