3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getCombinations($traits, $string = '', $i = 0) { $combinations = ''; if ($i >= count($traits)) return trim($string) . "\n"; else { foreach ($traits[$i] as $trait) { $combinations .= getCombinations($traits, "$string $trait", $i + 1); } } if($i==0) return explode("\n",$combinations); return $combinations; } $traits = array ( array('Happy', 'Sad', 'Angry', 'Hopeful'), array('Outgoing', 'Introverted'), array('Tall', 'Short', 'Medium'), array('Handsome', 'Plain', 'Ugly') ); $combinations = getCombinations($traits); print_r($combinations);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/X3i3p
function name:  (null)
number of ops:  9
compiled vars:  !0 = $traits, !1 = $combinations
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, <array>
   25     1        INIT_FCALL                                                   'getcombinations'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !1, $3
   27     5        INIT_FCALL                                                   'print_r'
          6        SEND_VAR                                                     !1
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function getcombinations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/X3i3p
function name:  getCombinations
number of ops:  35
compiled vars:  !0 = $traits, !1 = $string, !2 = $i, !3 = $combinations, !4 = $trait
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      ''
          2        RECV_INIT                                            !2      0
    4     3        ASSIGN                                                       !3, ''
    5     4        COUNT                                                ~6      !0
          5        IS_SMALLER_OR_EQUAL                                          ~6, !2
          6      > JMPZ                                                         ~7, ->11
    6     7    >   FRAMELESS_ICALL_1                trim                ~8      !1
          8        CONCAT                                               ~9      ~8, '%0A'
          9      > RETURN                                                       ~9
    5    10*       JMP                                                          ->26
    9    11    >   FETCH_DIM_R                                          ~10     !0, !2
         12      > FE_RESET_R                                           $11     ~10, ->25
         13    > > FE_FETCH_R                                                   $11, !4, ->25
   10    14    >   INIT_FCALL_BY_NAME                                           'getCombinations'
         15        SEND_VAR_EX                                                  !0
         16        ROPE_INIT                                         3  ~13     !1
         17        ROPE_ADD                                          1  ~13     ~13, '+'
         18        ROPE_END                                          2  ~12     ~13, !4
         19        SEND_VAL_EX                                                  ~12
         20        ADD                                                  ~15     !2, 1
         21        SEND_VAL_EX                                                  ~15
         22        DO_FCALL                                          0  $16     
         23        ASSIGN_OP                                         8          !3, $16
    9    24      > JMP                                                          ->13
         25    >   FE_FREE                                                      $11
   13    26        IS_EQUAL                                                     !2, 0
         27      > JMPZ                                                         ~18, ->33
         28    >   INIT_FCALL                                                   'explode'
         29        SEND_VAL                                                     '%0A'
         30        SEND_VAR                                                     !3
         31        DO_ICALL                                             $19     
         32      > RETURN                                                       $19
   14    33    > > RETURN                                                       !3
   15    34*     > RETURN                                                       null

End of function getcombinations

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
179.67 ms | 3969 KiB | 16 Q