3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decartProductExclusive($one, $two) { $result = []; for($i=0; $i<count($one); $i++) { for($j=0; $j<count($two); $j++) { if(!count(array_intersect((array)$one[$i], (array)$two[$j]))) { $result[]=array_merge((array)$one[$i], (array)$two[$j]); } } } return $result; } function createAssociation() { $args = func_get_args(); if(!count($args)) { return []; } $result = array_shift($args); while($array=array_shift($args)) { $result=decartProductExclusive($result, $array); } return $result; } $i[0] = ['a', 'b', 'c']; $i[1] = ['d', 'e']; $i[2] = ['a', 'b', 'c']; $i[3] = ['d', 'e']; $i[4] = ['f', 'g', 'h']; $result = call_user_func_array('createAssociation', $i); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PcnNf
function name:  (null)
number of ops:  19
compiled vars:  !0 = $i, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN_DIM                                               !0, 0
          1        OP_DATA                                                  <array>
   34     2        ASSIGN_DIM                                               !0, 1
          3        OP_DATA                                                  <array>
   35     4        ASSIGN_DIM                                               !0, 2
          5        OP_DATA                                                  <array>
   36     6        ASSIGN_DIM                                               !0, 3
          7        OP_DATA                                                  <array>
   37     8        ASSIGN_DIM                                               !0, 4
          9        OP_DATA                                                  <array>
   39    10        INIT_FCALL                                               'createassociation'
         11        SEND_ARRAY                                               !0
         12        CHECK_UNDEF_ARGS                                         
         13        DO_FCALL                                      0  $7      
         14        ASSIGN                                                   !1, $7
   41    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function decartproductexclusive:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 5
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 7
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 5
Branch analysis from position: 36
Branch analysis from position: 5
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 7
Branch analysis from position: 32
Branch analysis from position: 7
Branch analysis from position: 28
filename:       /in/PcnNf
function name:  decartProductExclusive
number of ops:  38
compiled vars:  !0 = $one, !1 = $two, !2 = $result, !3 = $i, !4 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->33
    7     5    >   ASSIGN                                                   !4, 0
          6      > JMP                                                      ->29
    9     7    >   INIT_FCALL                                               'array_intersect'
          8        FETCH_DIM_R                                      ~8      !0, !3
          9        CAST                                          7  ~9      ~8
         10        SEND_VAL                                                 ~9
         11        FETCH_DIM_R                                      ~10     !1, !4
         12        CAST                                          7  ~11     ~10
         13        SEND_VAL                                                 ~11
         14        DO_ICALL                                         $12     
         15        COUNT                                            ~13     $12
         16        BOOL_NOT                                         ~14     ~13
         17      > JMPZ                                                     ~14, ->28
   11    18    >   INIT_FCALL                                               'array_merge'
         19        FETCH_DIM_R                                      ~16     !0, !3
         20        CAST                                          7  ~17     ~16
         21        SEND_VAL                                                 ~17
         22        FETCH_DIM_R                                      ~18     !1, !4
         23        CAST                                          7  ~19     ~18
         24        SEND_VAL                                                 ~19
         25        DO_ICALL                                         $20     
         26        ASSIGN_DIM                                               !2
         27        OP_DATA                                                  $20
    7    28    >   PRE_INC                                                  !4
         29    >   COUNT                                            ~22     !1
         30        IS_SMALLER                                               !4, ~22
         31      > JMPNZ                                                    ~23, ->7
    5    32    >   PRE_INC                                                  !3
         33    >   COUNT                                            ~25     !0
         34        IS_SMALLER                                               !3, ~25
         35      > JMPNZ                                                    ~26, ->5
   15    36    > > RETURN                                                   !2
   16    37*     > RETURN                                                   null

End of function decartproductexclusive

Function createassociation:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
Branch analysis from position: 11
filename:       /in/PcnNf
function name:  createAssociation
number of ops:  23
compiled vars:  !0 = $args, !1 = $result, !2 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FUNC_GET_ARGS                                    ~3      
          1        ASSIGN                                                   !0, ~3
   21     2        COUNT                                            ~5      !0
          3        BOOL_NOT                                         ~6      ~5
          4      > JMPZ                                                     ~6, ->6
   23     5    > > RETURN                                                   <array>
   25     6    >   INIT_FCALL                                               'array_shift'
          7        SEND_REF                                                 !0
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
   26    10      > JMP                                                      ->16
   28    11    >   INIT_FCALL                                               'decartproductexclusive'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !2
         14        DO_FCALL                                      0  $9      
         15        ASSIGN                                                   !1, $9
   26    16    >   INIT_FCALL                                               'array_shift'
         17        SEND_REF                                                 !0
         18        DO_ICALL                                         $11     
         19        ASSIGN                                           ~12     !2, $11
         20      > JMPNZ                                                    ~12, ->11
   30    21    > > RETURN                                                   !1
   31    22*     > RETURN                                                   null

End of function createassociation

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
189.32 ms | 1407 KiB | 23 Q