3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = array(1, 2, 3, 4); $array2 = array(1, 2, 5, 6); $array3 = array(1, 2, 6); // The result should contain ONLY: 1 and 2. 6 is not in all 3 results $result = array(); for ($i = 1; $i <= 3; $i++) { $array = 'array' . $i; if (empty($result)) { $result = ${$array}; } else { $inBoth = array_intersect($result, ${$array}); //$notInBoth = array_diff($result, ${$array}); $result = array_diff($result, array_unique(array_merge($result, $inBoth))); } } var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 6
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 6
Branch analysis from position: 34
Branch analysis from position: 6
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 6
Branch analysis from position: 34
Branch analysis from position: 6
filename:       /in/gtUKb
function name:  (null)
number of ops:  38
compiled vars:  !0 = $array1, !1 = $array2, !2 = $array3, !3 = $result, !4 = $i, !5 = $array, !6 = $inBoth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    8     3        ASSIGN                                                   !3, <array>
   10     4        ASSIGN                                                   !4, 1
          5      > JMP                                                      ->32
   12     6    >   CONCAT                                           ~12     'array', !4
          7        ASSIGN                                                   !5, ~12
   14     8        ISSET_ISEMPTY_CV                                         !3
          9      > JMPZ                                                     ~14, ->13
   16    10    >   FETCH_R                      local               ~15     !5
         11        ASSIGN                                                   !3, ~15
         12      > JMP                                                      ->31
   20    13    >   INIT_FCALL                                               'array_intersect'
         14        SEND_VAR                                                 !3
         15        FETCH_R                      local               ~17     !5
         16        SEND_VAL                                                 ~17
         17        DO_ICALL                                         $18     
         18        ASSIGN                                                   !6, $18
   22    19        INIT_FCALL                                               'array_diff'
         20        SEND_VAR                                                 !3
         21        INIT_FCALL                                               'array_unique'
         22        INIT_FCALL                                               'array_merge'
         23        SEND_VAR                                                 !3
         24        SEND_VAR                                                 !6
         25        DO_ICALL                                         $20     
         26        SEND_VAR                                                 $20
         27        DO_ICALL                                         $21     
         28        SEND_VAR                                                 $21
         29        DO_ICALL                                         $22     
         30        ASSIGN                                                   !3, $22
   10    31    >   PRE_INC                                                  !4
         32    >   IS_SMALLER_OR_EQUAL                                      !4, 3
         33      > JMPNZ                                                    ~25, ->6
   26    34    >   INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.78 ms | 1400 KiB | 23 Q