3v4l.org

run code in 300+ PHP versions simultaneously
<?php function doLoad(array $weights, $remainingWeight, array $sequence = []) { if ($remainingWeight === 0) { return [$sequence]; } if (empty($weights)) { return []; } $container = array_shift($weights); $sequences = doLoad($weights, $remainingWeight, $sequence); if ($container <= $remainingWeight) { $sequence[] = $container; $sequences = array_merge($sequences, $this->doLoad($weights, ($remainingWeight - $container), $sequence)); } return $sequences; } $weights = [ 1, 3, 5, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113 ]; var_dump(doLoad($weights, 381));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7tHsa
function name:  (null)
number of ops:  9
compiled vars:  !0 = $weights
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   51     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'doload'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 381
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function doload:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 36
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/7tHsa
function name:  doLoad
number of ops:  38
compiled vars:  !0 = $weights, !1 = $remainingWeight, !2 = $sequence, !3 = $container, !4 = $sequences
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
    5     3        IS_IDENTICAL                                             !1, 0
          4      > JMPZ                                                     ~5, ->7
    6     5    >   INIT_ARRAY                                       ~6      !2
          6      > RETURN                                                   ~6
    8     7    >   ISSET_ISEMPTY_CV                                         !0
          8      > JMPZ                                                     ~7, ->10
    9     9    > > RETURN                                                   <array>
   11    10    >   INIT_FCALL                                               'array_shift'
         11        SEND_REF                                                 !0
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !3, $8
   12    14        INIT_FCALL_BY_NAME                                       'doLoad'
         15        SEND_VAR_EX                                              !0
         16        SEND_VAR_EX                                              !1
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $10     
         19        ASSIGN                                                   !4, $10
   13    20        IS_SMALLER_OR_EQUAL                                      !3, !1
         21      > JMPZ                                                     ~12, ->36
   14    22    >   ASSIGN_DIM                                               !2
         23        OP_DATA                                                  !3
   15    24        INIT_FCALL                                               'array_merge'
         25        SEND_VAR                                                 !4
         26        FETCH_THIS                                       $14     
         27        INIT_METHOD_CALL                                         $14, 'doLoad'
         28        SEND_VAR_EX                                              !0
         29        SUB                                              ~15     !1, !3
         30        SEND_VAL_EX                                              ~15
         31        SEND_VAR_EX                                              !2
         32        DO_FCALL                                      0  $16     
         33        SEND_VAR                                                 $16
         34        DO_ICALL                                         $17     
         35        ASSIGN                                                   !4, $17
   17    36    > > RETURN                                                   !4
   18    37*     > RETURN                                                   null

End of function doload

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
233.43 ms | 1403 KiB | 20 Q