3v4l.org

run code in 300+ PHP versions simultaneously
<?php $set1 = ['A', 'B', 'C']; $set2 = [1, 2, 3]; function perms( $set1, $set2) { $perms = array(); $i = count( $set1); while( $i > 0) { $perms[] = p( $set1, $set2); $set1[] = array_shift( $set1); $i--; } return $perms; } function p( $set1, $set2) { $p = array(); for( $i = 0; $i < count( $set1); $i++) { $el1 = $set1[ $i ]; $el2 = $set2[ $i ]; $p[] = $el1.$el2; } return implode( ', ', $p); } print_r( perms( $set1, $set2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CAZZK
function name:  (null)
number of ops:  10
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>
   28     2        INIT_FCALL                                               'print_r'
          3        INIT_FCALL                                               'perms'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function perms:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 6
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 6
Branch analysis from position: 20
Branch analysis from position: 6
filename:       /in/CAZZK
function name:  perms
number of ops:  22
compiled vars:  !0 = $set1, !1 = $set2, !2 = $perms, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        ASSIGN                                                   !2, <array>
    8     3        COUNT                                            ~5      !0
          4        ASSIGN                                                   !3, ~5
    9     5      > JMP                                                      ->18
   10     6    >   INIT_FCALL_BY_NAME                                       'p'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $8      
         10        ASSIGN_DIM                                               !2
         11        OP_DATA                                                  $8
   11    12        INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !0
         14        DO_ICALL                                         $10     
         15        ASSIGN_DIM                                               !0
         16        OP_DATA                                                  $10
   12    17        PRE_DEC                                                  !3
    9    18    >   IS_SMALLER                                               0, !3
         19      > JMPNZ                                                    ~12, ->6
   15    20    > > RETURN                                                   !2
   16    21*     > RETURN                                                   null

End of function perms

Function p:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 5
Branch analysis from position: 16
Branch analysis from position: 5
filename:       /in/CAZZK
function name:  p
number of ops:  22
compiled vars:  !0 = $set1, !1 = $set2, !2 = $p, !3 = $i, !4 = $el1, !5 = $el2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        ASSIGN                                                   !2, <array>
   20     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->13
   21     5    >   FETCH_DIM_R                                      ~8      !0, !3
          6        ASSIGN                                                   !4, ~8
   22     7        FETCH_DIM_R                                      ~10     !1, !3
          8        ASSIGN                                                   !5, ~10
   23     9        CONCAT                                           ~13     !4, !5
         10        ASSIGN_DIM                                               !2
         11        OP_DATA                                                  ~13
   20    12        PRE_INC                                                  !3
         13    >   COUNT                                            ~15     !0
         14        IS_SMALLER                                               !3, ~15
         15      > JMPNZ                                                    ~16, ->5
   25    16    >   INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%2C+'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $17     
         20      > RETURN                                                   $17
   26    21*     > RETURN                                                   null

End of function p

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.37 ms | 1394 KiB | 20 Q