3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getCombinations($traits) { $combinations = ['']; foreach( $traits as $trait_level ) { $new_combinations = []; foreach ($combinations as $comb) { foreach ($trait_level as $trait) { $new_combinations[] = "$comb $trait"; } } $combinations = $new_combinations; } return $combinations; } $traits = array ( array('Happy', 'Sad', 'Angry', 'Hopeful'), array('Outgoing', 'Introverted'), array('Tall', 'Short', 'Medium'), array('Handsome', 'Plain', 'Ugly') ); $combinations = getCombinations($traits); foreach($combinations as $item) { echo $item.'<BR>'; }
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/kvWns
function name:  (null)
number of ops:  12
compiled vars:  !0 = $traits, !1 = $combinations, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ASSIGN                                                   !0, <array>
   28     1        INIT_FCALL                                               'getcombinations'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   31     5      > FE_RESET_R                                       $6      !1, ->10
          6    > > FE_FETCH_R                                               $6, !2, ->10
   33     7    >   CONCAT                                           ~7      !2, '%3CBR%3E'
          8        ECHO                                                     ~7
   31     9      > JMP                                                      ->6
         10    >   FE_FREE                                                  $6
   34    11      > RETURN                                                   1

Function getcombinations:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 15
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/kvWns
function name:  getCombinations
number of ops:  23
compiled vars:  !0 = $traits, !1 = $combinations, !2 = $trait_level, !3 = $new_combinations, !4 = $comb, !5 = $trait
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2      > FE_RESET_R                                       $7      !0, ->20
          3    > > FE_FETCH_R                                               $7, !2, ->20
    7     4    >   ASSIGN                                                   !3, <array>
    8     5      > FE_RESET_R                                       $9      !1, ->17
          6    > > FE_FETCH_R                                               $9, !4, ->17
   10     7    > > FE_RESET_R                                       $10     !2, ->15
          8    > > FE_FETCH_R                                               $10, !5, ->15
   12     9    >   ROPE_INIT                                     3  ~13     !4
         10        ROPE_ADD                                      1  ~13     ~13, '+'
         11        ROPE_END                                      2  ~12     ~13, !5
         12        ASSIGN_DIM                                               !3
         13        OP_DATA                                                  ~12
   10    14      > JMP                                                      ->8
         15    >   FE_FREE                                                  $10
    8    16      > JMP                                                      ->6
         17    >   FE_FREE                                                  $9
   15    18        ASSIGN                                                   !1, !3
    5    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $7
   17    21      > RETURN                                                   !1
   18    22*     > RETURN                                                   null

End of function getcombinations

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.21 ms | 1403 KiB | 14 Q