3v4l.org

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

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

End of function getallwordcombos

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.13 ms | 1400 KiB | 21 Q