3v4l.org

run code in 300+ PHP versions simultaneously
<?php //The values in this arrays contains the names of the indexes (keys) that should exist in the data array $required = array('key1', 'key2', 'key30' ); $data = array( 'key1' => 10, 'key2' => 20, 'key3' => 30, 'key4' => 40, 'dato' => 60 ); if(count(array_intersect_key(array_flip($required), $data)) === count($required)) { echo "all exist"; }else{ echo "fail"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DTS9f
function name:  (null)
number of ops:  17
compiled vars:  !0 = $required, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    6     1        ASSIGN                                                   !1, <array>
   14     2        INIT_FCALL                                               'array_intersect_key'
          3        INIT_FCALL                                               'array_flip'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        SEND_VAR                                                 $4
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $5      
          9        COUNT                                            ~6      $5
         10        COUNT                                            ~7      !0
         11        IS_IDENTICAL                                             ~6, ~7
         12      > JMPZ                                                     ~8, ->15
   15    13    >   ECHO                                                     'all+exist'
         14      > JMP                                                      ->16
   17    15    >   ECHO                                                     'fail'
   18    16    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.63 ms | 1386 KiB | 17 Q