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 == size( $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/Jebm8
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 = 10, Position 2 = 11
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 25
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 25
Branch analysis from position: 38
Branch analysis from position: 25
Branch analysis from position: 21
filename:       /in/Jebm8
function name:  perms
number of ops:  48
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        INIT_FCALL_BY_NAME                                       'size'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $8      
          7        SUB                                              ~9      $8, 1
          8        IS_EQUAL                                                 !2, ~9
          9      > JMPZ                                                     ~10, ->11
    9    10    > > RETURN                                                   <array>
   12    11    > > FE_RESET_R                                       $11     !0, ->21
         12    > > FE_FETCH_R                                               $11, !4, ->21
   13    13    > > FE_RESET_R                                       $12     !1, ->19
         14    > > FE_FETCH_R                                               $12, !5, ->19
   14    15    >   CONCAT                                           ~14     !4, !5
         16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  ~14
   13    18      > JMP                                                      ->14
         19    >   FE_FREE                                                  $12
   12    20      > JMP                                                      ->12
         21    >   FE_FREE                                                  $11
   18    22        PRE_INC                                                  !2
   19    23        ASSIGN                                                   !6, 0
         24      > JMP                                                      ->36
   20    25    >   INIT_FCALL                                               'array_shift'
         26        SEND_REF                                                 !0
         27        DO_ICALL                                         $18     
         28        ASSIGN_DIM                                               !0
         29        OP_DATA                                                  $18
   21    30        INIT_FCALL                                               'array_shift'
         31        SEND_REF                                                 !1
         32        DO_ICALL                                         $20     
         33        ASSIGN_DIM                                               !1
         34        OP_DATA                                                  $20
   19    35        PRE_INC                                                  !6
         36    >   IS_SMALLER                                               !6, !2
         37      > JMPNZ                                                    ~22, ->25
   24    38    >   INIT_FCALL                                               'array_merge'
         39        SEND_VAR                                                 !3
         40        INIT_FCALL_BY_NAME                                       'perms'
         41        SEND_VAR_EX                                              !0
         42        SEND_VAR_EX                                              !1
         43        DO_FCALL                                      0  $23     
         44        SEND_VAR                                                 $23
         45        DO_ICALL                                         $24     
         46      > RETURN                                                   $24
   25    47*     > RETURN                                                   null

End of function perms

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.25 ms | 1403 KiB | 20 Q