3v4l.org

run code in 300+ PHP versions simultaneously
<?php function computeAllPermutations(array $words, array $separators): array { switch (count($words)) { case 0: return []; case 1: return [$words[0]]; default: $permutations = []; foreach (computeAllPermutations(array_slice($words, 1), $separators) as $subPermutation) { foreach ($separators as $separator) { $permutations[] = $words[0] . $separator . $subPermutation; } } return $permutations; } } $char = ["-", "_", "|", "+", "~"]; $MyString = "this is test string"; $words = preg_split('/\h+/', $MyString); print_r(computeAllPermutations($words, $char));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKtYC
function name:  (null)
number of ops:  15
compiled vars:  !0 = $char, !1 = $MyString, !2 = $words
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, <array>
   22     1        ASSIGN                                                   !1, 'this+is+test+string'
   24     2        INIT_FCALL                                               'preg_split'
          3        SEND_VAL                                                 '%2F%5Ch%2B%2F'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   25     7        INIT_FCALL                                               'print_r'
          8        INIT_FCALL                                               'computeallpermutations'
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !0
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function computeallpermutations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 36
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 36
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 34
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/uKtYC
function name:  computeAllPermutations
number of ops:  43
compiled vars:  !0 = $words, !1 = $separators, !2 = $permutations, !3 = $subPermutation, !4 = $separator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        COUNT                                            ~5      !0
    6     3        CASE                                                     ~5, 0
          4      > JMPNZ                                                    ~6, ->8
    8     5    >   CASE                                                     ~5, 1
          6      > JMPNZ                                                    ~6, ->10
          7    > > JMP                                                      ->15
    7     8    >   FREE                                                     ~5
          9      > RETURN                                                   <array>
    9    10    >   FETCH_DIM_R                                      ~7      !0, 0
         11        INIT_ARRAY                                       ~8      ~7
         12        VERIFY_RETURN_TYPE                                       ~8
         13        FREE                                                     ~5
         14      > RETURN                                                   ~8
   11    15    >   ASSIGN                                                   !2, <array>
   12    16        INIT_FCALL_BY_NAME                                       'computeAllPermutations'
         17        INIT_FCALL                                               'array_slice'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 1
         20        DO_ICALL                                         $10     
         21        SEND_VAR_NO_REF_EX                                       $10
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0  $11     
         24      > FE_RESET_R                                       $12     $11, ->36
         25    > > FE_FETCH_R                                               $12, !3, ->36
   13    26    > > FE_RESET_R                                       $13     !1, ->34
         27    > > FE_FETCH_R                                               $13, !4, ->34
   14    28    >   FETCH_DIM_R                                      ~15     !0, 0
         29        CONCAT                                           ~16     ~15, !4
         30        CONCAT                                           ~17     ~16, !3
         31        ASSIGN_DIM                                               !2
         32        OP_DATA                                                  ~17
   13    33      > JMP                                                      ->27
         34    >   FE_FREE                                                  $13
   12    35      > JMP                                                      ->25
         36    >   FE_FREE                                                  $12
   17    37        VERIFY_RETURN_TYPE                                       !2
         38        FREE                                                     ~5
         39      > RETURN                                                   !2
         40*       FREE                                                     ~5
   19    41*       VERIFY_RETURN_TYPE                                       
         42*     > RETURN                                                   null

End of function computeallpermutations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
232.74 ms | 962 KiB | 17 Q