3v4l.org

run code in 300+ PHP versions simultaneously
<?php function combinaisons($chaine, $prefix = '') { if(strlen($chaine) == strlen($prefix)) { yield $prefix; return; } $caracteres = str_split($chaine, 1); foreach($caracteres as $caractere) { $solutions = combinaisons($chaine, $prefix.$caractere); foreach($solutions as $solution) yield $solution; } } $combinaisons = combinaisons('abc', 4); foreach($combinaisons as $combinaison) echo $combinaison.'\n';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/BvQtE
function name:  (null)
number of ops:  12
compiled vars:  !0 = $combinaisons, !1 = $combinaison
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'combinaisons'
          1        SEND_VAL                                                 'abc'
          2        SEND_VAL                                                 4
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
   25     5      > FE_RESET_R                                       $4      !0, ->10
          6    > > FE_FETCH_R                                               $4, !1, ->10
   26     7    >   CONCAT                                           ~5      !1, '%5Cn'
          8        ECHO                                                     ~5
   25     9      > JMP                                                      ->6
         10    >   FE_FREE                                                  $4
   26    11      > RETURN                                                   1

Function combinaisons:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 26
Branch analysis from position: 28
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 28
filename:       /in/BvQtE
function name:  combinaisons
number of ops:  30
compiled vars:  !0 = $chaine, !1 = $prefix, !2 = $caracteres, !3 = $caractere, !4 = $solutions, !5 = $solution
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      ''
          2        GENERATOR_CREATE                                         
    5     3        STRLEN                                           ~6      !0
          4        STRLEN                                           ~7      !1
          5        IS_EQUAL                                                 ~6, ~7
          6      > JMPZ                                                     ~8, ->9
    6     7    >   YIELD                                                    !1
    7     8      > GENERATOR_RETURN                                         
   10     9    >   INIT_FCALL                                               'str_split'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 1
         12        DO_ICALL                                         $10     
         13        ASSIGN                                                   !2, $10
   12    14      > FE_RESET_R                                       $12     !2, ->28
         15    > > FE_FETCH_R                                               $12, !3, ->28
   14    16    >   INIT_FCALL_BY_NAME                                       'combinaisons'
         17        SEND_VAR_EX                                              !0
         18        CONCAT                                           ~13     !1, !3
         19        SEND_VAL_EX                                              ~13
         20        DO_FCALL                                      0  $14     
         21        ASSIGN                                                   !4, $14
   16    22      > FE_RESET_R                                       $16     !4, ->26
         23    > > FE_FETCH_R                                               $16, !5, ->26
   17    24    >   YIELD                                                    !5
   16    25      > JMP                                                      ->23
         26    >   FE_FREE                                                  $16
   12    27      > JMP                                                      ->15
         28    >   FE_FREE                                                  $12
   21    29      > GENERATOR_RETURN                                         

End of function combinaisons

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.64 ms | 1394 KiB | 16 Q