3v4l.org

run code in 300+ PHP versions simultaneously
<?php $set1 = ['A', 'B', 'C']; $set2 = [1, 2, 3]; function perms( $set1, $set2, $i) { $perms = array(); if( $i == count( $set1) - 1) { return array(); } foreach( $set1 as $n1) { foreach( $set2 as $n2) { $perms[] = $n1 . $n2; } } $i++; for( $j = 0; $j < $i; $j++) { $set1[] = array_shift( $set1); $set2[] = array_shift( $set2); } return array_merge( $perms, perms( $set1, $set2)); } var_dump( perms( $set1, $set2, 0));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qhsJC
function name:  (null)
number of ops:  11
compiled vars:  !0 = $set1, !1 = $set2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, <array>
   27     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'perms'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function perms:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 17
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 23
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 23
Branch analysis from position: 36
Branch analysis from position: 23
Branch analysis from position: 19
filename:       /in/qhsJC
function name:  perms
number of ops:  46
compiled vars:  !0 = $set1, !1 = $set2, !2 = $i, !3 = $perms, !4 = $n1, !5 = $n2, !6 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    6     3        ASSIGN                                                   !3, <array>
    8     4        COUNT                                            ~8      !0
          5        SUB                                              ~9      ~8, 1
          6        IS_EQUAL                                                 !2, ~9
          7      > JMPZ                                                     ~10, ->9
    9     8    > > RETURN                                                   <array>
   12     9    > > FE_RESET_R                                       $11     !0, ->19
         10    > > FE_FETCH_R                                               $11, !4, ->19
   13    11    > > FE_RESET_R                                       $12     !1, ->17
         12    > > FE_FETCH_R                                               $12, !5, ->17
   14    13    >   CONCAT                                           ~14     !4, !5
         14        ASSIGN_DIM                                               !3
         15        OP_DATA                                                  ~14
   13    16      > JMP                                                      ->12
         17    >   FE_FREE                                                  $12
   12    18      > JMP                                                      ->10
         19    >   FE_FREE                                                  $11
   18    20        PRE_INC                                                  !2
   19    21        ASSIGN                                                   !6, 0
         22      > JMP                                                      ->34
   20    23    >   INIT_FCALL                                               'array_shift'
         24        SEND_REF                                                 !0
         25        DO_ICALL                                         $18     
         26        ASSIGN_DIM                                               !0
         27        OP_DATA                                                  $18
   21    28        INIT_FCALL                                               'array_shift'
         29        SEND_REF                                                 !1
         30        DO_ICALL                                         $20     
         31        ASSIGN_DIM                                               !1
         32        OP_DATA                                                  $20
   19    33        PRE_INC                                                  !6
         34    >   IS_SMALLER                                               !6, !2
         35      > JMPNZ                                                    ~22, ->23
   24    36    >   INIT_FCALL                                               'array_merge'
         37        SEND_VAR                                                 !3
         38        INIT_FCALL_BY_NAME                                       'perms'
         39        SEND_VAR_EX                                              !0
         40        SEND_VAR_EX                                              !1
         41        DO_FCALL                                      0  $23     
         42        SEND_VAR                                                 $23
         43        DO_ICALL                                         $24     
         44      > RETURN                                                   $24
   25    45*     > RETURN                                                   null

End of function perms

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.03 ms | 1402 KiB | 20 Q