3v4l.org

run code in 300+ PHP versions simultaneously
<?php $words=array("A", "B", "C", "D"); $combos=array(); getAllWordCombos($words,$combos, array()); print_r($combos); function getAllWordCombos($words, &$combos, $partial) { if (count($words)==1) $combos[]=array_merge($partial,$words); else { foreach ($words as $i=>$first) { $cwords=array_slice($words,0); array_splice($cwords,$i,1); getAllWordCombos($cwords, $combos, array_merge($partial,array($first))); } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AWsSe
function name:  (null)
number of ops:  11
compiled vars:  !0 = $words, !1 = $combos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL_BY_NAME                                       'getAllWordCombos'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0          
    6     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   17    10      > RETURN                                                   1

Function getallwordcombos:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 37
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 37
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/AWsSe
function name:  getAllWordCombos
number of ops:  39
compiled vars:  !0 = $words, !1 = $combos, !2 = $partial, !3 = $first, !4 = $i, !5 = $cwords
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    9     3        COUNT                                            ~6      !0
          4        IS_EQUAL                                                 ~6, 1
          5      > JMPZ                                                     ~7, ->13
          6    >   INIT_FCALL                                               'array_merge'
          7        SEND_VAR                                                 !2
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $9      
         10        ASSIGN_DIM                                               !1
         11        OP_DATA                                                  $9
         12      > JMP                                                      ->38
   11    13    > > FE_RESET_R                                       $10     !0, ->37
         14    > > FE_FETCH_R                                       ~11     $10, !3, ->37
         15    >   ASSIGN                                                   !4, ~11
   12    16        INIT_FCALL                                               'array_slice'
         17        SEND_VAR                                                 !0
         18        SEND_VAL                                                 0
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !5, $13
   13    21        INIT_FCALL                                               'array_splice'
         22        SEND_REF                                                 !5
         23        SEND_VAR                                                 !4
         24        SEND_VAL                                                 1
         25        DO_ICALL                                                 
   14    26        INIT_FCALL_BY_NAME                                       'getAllWordCombos'
         27        SEND_VAR_EX                                              !5
         28        SEND_VAR_EX                                              !1
         29        INIT_FCALL                                               'array_merge'
         30        SEND_VAR                                                 !2
         31        INIT_ARRAY                                       ~16     !3
         32        SEND_VAL                                                 ~16
         33        DO_ICALL                                         $17     
         34        SEND_VAR_NO_REF_EX                                       $17
         35        DO_FCALL                                      0          
   11    36      > JMP                                                      ->14
         37    >   FE_FREE                                                  $10
   17    38    > > RETURN                                                   null

End of function getallwordcombos

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.47 ms | 1392 KiB | 21 Q