3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values1 = [1, 2, 3, 4, 5]; $values2 = [3, 4, 6, 7]; // You can construct the set iteratively $set1 = []; foreach ([1, 2, 3, 4, 5] as $val) { $set1[$val] = true; } assert(array_keys($set1) == [1, 2, 3, 4, 5]); // Or all at once $set2 = array_fill_keys($values2, true); assert(array_keys($set2) == [3, 4, 6, 7]); // Set operations $union = $set1 + $set2; assert(array_keys($union) == [1, 2, 3, 4, 5, 6, 7]); $intersection = array_intersect_key($set1, $set2); assert(array_keys($intersection) == [3, 4]); // This one's still quite ugly $exclusion = array_diff_key($set1, $set2) + array_diff_key($set2, $set1); assert(array_keys($exclusion) == [1, 2, 5, 6, 7]); $difference = array_diff_key($set1, $set2); assert(array_keys($difference) == [1, 2, 5]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/5BF1c
function name:  (null)
number of ops:  91
compiled vars:  !0 = $values1, !1 = $values2, !2 = $set1, !3 = $val, !4 = $set2, !5 = $union, !6 = $intersection, !7 = $exclusion, !8 = $difference
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    7     2        ASSIGN                                                   !2, <array>
    8     3      > FE_RESET_R                                       $12     <array>, ->8
          4    > > FE_FETCH_R                                               $12, !3, ->8
    9     5    >   ASSIGN_DIM                                               !2, !3
          6        OP_DATA                                                  <true>
    8     7      > JMP                                                      ->4
          8    >   FE_FREE                                                  $12
   11     9        ASSERT_CHECK                                             
         10        INIT_FCALL                                               'assert'
         11        INIT_FCALL                                               'array_keys'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $14     
         14        IS_EQUAL                                         ~15     $14, <array>
         15        SEND_VAL                                                 ~15
         16        SEND_VAL                                                 'assert%28array_keys%28%24set1%29+%3D%3D+%5B1%2C+2%2C+3%2C+4%2C+5%5D%29'
         17        DO_ICALL                                                 
   14    18        INIT_FCALL                                               'array_fill_keys'
         19        SEND_VAR                                                 !1
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $17     
         22        ASSIGN                                                   !4, $17
   15    23        ASSERT_CHECK                                             
         24        INIT_FCALL                                               'assert'
         25        INIT_FCALL                                               'array_keys'
         26        SEND_VAR                                                 !4
         27        DO_ICALL                                         $19     
         28        IS_EQUAL                                         ~20     $19, <array>
         29        SEND_VAL                                                 ~20
         30        SEND_VAL                                                 'assert%28array_keys%28%24set2%29+%3D%3D+%5B3%2C+4%2C+6%2C+7%5D%29'
         31        DO_ICALL                                                 
   18    32        ADD                                              ~22     !2, !4
         33        ASSIGN                                                   !5, ~22
   19    34        ASSERT_CHECK                                             
         35        INIT_FCALL                                               'assert'
         36        INIT_FCALL                                               'array_keys'
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                         $24     
         39        IS_EQUAL                                         ~25     $24, <array>
         40        SEND_VAL                                                 ~25
         41        SEND_VAL                                                 'assert%28array_keys%28%24union%29+%3D%3D+%5B1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7%5D%29'
         42        DO_ICALL                                                 
   21    43        INIT_FCALL                                               'array_intersect_key'
         44        SEND_VAR                                                 !2
         45        SEND_VAR                                                 !4
         46        DO_ICALL                                         $27     
         47        ASSIGN                                                   !6, $27
   22    48        ASSERT_CHECK                                             
         49        INIT_FCALL                                               'assert'
         50        INIT_FCALL                                               'array_keys'
         51        SEND_VAR                                                 !6
         52        DO_ICALL                                         $29     
         53        IS_EQUAL                                         ~30     $29, <array>
         54        SEND_VAL                                                 ~30
         55        SEND_VAL                                                 'assert%28array_keys%28%24intersection%29+%3D%3D+%5B3%2C+4%5D%29'
         56        DO_ICALL                                                 
   25    57        INIT_FCALL                                               'array_diff_key'
         58        SEND_VAR                                                 !2
         59        SEND_VAR                                                 !4
         60        DO_ICALL                                         $32     
         61        INIT_FCALL                                               'array_diff_key'
         62        SEND_VAR                                                 !4
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                         $33     
         65        ADD                                              ~34     $32, $33
         66        ASSIGN                                                   !7, ~34
   26    67        ASSERT_CHECK                                             
         68        INIT_FCALL                                               'assert'
         69        INIT_FCALL                                               'array_keys'
         70        SEND_VAR                                                 !7
         71        DO_ICALL                                         $36     
         72        IS_EQUAL                                         ~37     $36, <array>
         73        SEND_VAL                                                 ~37
         74        SEND_VAL                                                 'assert%28array_keys%28%24exclusion%29+%3D%3D+%5B1%2C+2%2C+5%2C+6%2C+7%5D%29'
         75        DO_ICALL                                                 
   28    76        INIT_FCALL                                               'array_diff_key'
         77        SEND_VAR                                                 !2
         78        SEND_VAR                                                 !4
         79        DO_ICALL                                         $39     
         80        ASSIGN                                                   !8, $39
   29    81        ASSERT_CHECK                                             
         82        INIT_FCALL                                               'assert'
         83        INIT_FCALL                                               'array_keys'
         84        SEND_VAR                                                 !8
         85        DO_ICALL                                         $41     
         86        IS_EQUAL                                         ~42     $41, <array>
         87        SEND_VAL                                                 ~42
         88        SEND_VAL                                                 'assert%28array_keys%28%24difference%29+%3D%3D+%5B1%2C+2%2C+5%5D%29'
         89        DO_ICALL                                                 
         90      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.24 ms | 1027 KiB | 18 Q