3v4l.org

run code in 300+ PHP versions simultaneously
<?php function chunkOverloadLast(array $array, int $size) { $result = array_chunk($array, $size); if (count($array) % $size) { $result[] = array_merge(...array_splice($result, -2)); } return $result; } $languages = ['php', 'mysql', 'java', 'nodejs', 'ruby', 'go', 'c#']; echo json_encode(chunkOverloadLast($languages, 2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Lffu5
function name:  (null)
number of ops:  10
compiled vars:  !0 = $languages
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'json_encode'
          2        INIT_FCALL                                               'chunkoverloadlast'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 2
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                         $3      
          8        ECHO                                                     $3
          9      > RETURN                                                   1

Function chunkoverloadlast:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/Lffu5
function name:  chunkOverloadLast
number of ops:  22
compiled vars:  !0 = $array, !1 = $size, !2 = $result
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_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
    5     7        COUNT                                            ~5      !0
          8        MOD                                              ~6      ~5, !1
          9      > JMPZ                                                     ~6, ->20
    6    10    >   INIT_FCALL                                               'array_merge'
         11        INIT_FCALL                                               'array_splice'
         12        SEND_REF                                                 !2
         13        SEND_VAL                                                 -2
         14        DO_ICALL                                         $8      
         15        SEND_UNPACK                                              $8
         16        CHECK_UNDEF_ARGS                                         
         17        DO_ICALL                                         $9      
         18        ASSIGN_DIM                                               !2
         19        OP_DATA                                                  $9
    8    20    > > RETURN                                                   !2
    9    21*     > RETURN                                                   null

End of function chunkoverloadlast

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.67 ms | 1004 KiB | 18 Q