3v4l.org

run code in 300+ PHP versions simultaneously
<?php function computeCombination(array $source,$picks,$startIndex=0,array $pad=array()) { if($picks<=0) { return $pad; } elseif($picks>=count($source)-$startIndex) { return array_merge($pad,array_slice($source,$startIndex)); } $result=array(); foreach(range($startIndex,count($source)-$picks) as $subStartIndex) { $subPad=$pad; $subPad[]=$source[$subStartIndex]; $result=array_merge($result,array(computeCombination($source,$picks-1,$subStartIndex+1,$subPad))); } return $result; } print_r(computeCombination(array(1,2,3,4,5),2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Uoe2H
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'computecombination'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 2
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function computecombination:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 29, Position 2 = 49
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 49
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/Uoe2H
function name:  computeCombination
number of ops:  52
compiled vars:  !0 = $source, !1 = $picks, !2 = $startIndex, !3 = $pad, !4 = $result, !5 = $subStartIndex, !6 = $subPad
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      0
          3        RECV_INIT                                        !3      <array>
    4     4        IS_SMALLER_OR_EQUAL                                      !1, 0
          5      > JMPZ                                                     ~7, ->8
    6     6    > > RETURN                                                   !3
          7*       JMP                                                      ->21
    8     8    >   COUNT                                            ~8      !0
          9        SUB                                              ~9      ~8, !2
         10        IS_SMALLER_OR_EQUAL                                      ~9, !1
         11      > JMPZ                                                     ~10, ->21
   10    12    >   INIT_FCALL                                               'array_merge'
         13        SEND_VAR                                                 !3
         14        INIT_FCALL                                               'array_slice'
         15        SEND_VAR                                                 !0
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                         $12     
         20      > RETURN                                                   $12
   12    21    >   ASSIGN                                                   !4, <array>
   13    22        INIT_FCALL                                               'range'
         23        SEND_VAR                                                 !2
         24        COUNT                                            ~14     !0
         25        SUB                                              ~15     ~14, !1
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                         $16     
         28      > FE_RESET_R                                       $17     $16, ->49
         29    > > FE_FETCH_R                                               $17, !5, ->49
   15    30    >   ASSIGN                                                   !6, !3
   16    31        FETCH_DIM_R                                      ~20     !0, !5
         32        ASSIGN_DIM                                               !6
         33        OP_DATA                                                  ~20
   17    34        INIT_FCALL                                               'array_merge'
         35        SEND_VAR                                                 !4
         36        INIT_FCALL_BY_NAME                                       'computeCombination'
         37        SEND_VAR_EX                                              !0
         38        SUB                                              ~21     !1, 1
         39        SEND_VAL_EX                                              ~21
         40        ADD                                              ~22     !5, 1
         41        SEND_VAL_EX                                              ~22
         42        SEND_VAR_EX                                              !6
         43        DO_FCALL                                      0  $23     
         44        INIT_ARRAY                                       ~24     $23
         45        SEND_VAL                                                 ~24
         46        DO_ICALL                                         $25     
         47        ASSIGN                                                   !4, $25
   13    48      > JMP                                                      ->29
         49    >   FE_FREE                                                  $17
   19    50      > RETURN                                                   !4
   20    51*     > RETURN                                                   null

End of function computecombination

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.18 ms | 1403 KiB | 22 Q