3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_key_match($target, $match) { $targetKeys = array_keys($target); $diff = array_diff($target, $match); return ($diff == array_diff($diff, $match)); } print_r(array_diff([1, 2, 3, 4], [1, 4])); function test($target, $match, $expect) { return sprintf( "Target %s, Match %s: %s\n", var_export($target, true), var_export($match, true), (array_key_match($target, $match) == $expect) ? 'true' : 'false' ); } print test([1, 2, 3, 4, 5], [2, 3], true); print test(['a', 'b', 'c'], ['c', 'b'], true); print test([1, 2, 3, 4, 5], [4, 5, 6], false);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4ZlSY
function name:  (null)
number of ops:  26
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'array_diff'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        DO_ICALL                                         $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   23     7        INIT_FCALL                                               'test'
          8        SEND_VAL                                                 <array>
          9        SEND_VAL                                                 <array>
         10        SEND_VAL                                                 <true>
         11        DO_FCALL                                      0  $2      
         12        ECHO                                                     $2
   24    13        INIT_FCALL                                               'test'
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <array>
         16        SEND_VAL                                                 <true>
         17        DO_FCALL                                      0  $3      
         18        ECHO                                                     $3
   25    19        INIT_FCALL                                               'test'
         20        SEND_VAL                                                 <array>
         21        SEND_VAL                                                 <array>
         22        SEND_VAL                                                 <false>
         23        DO_FCALL                                      0  $4      
         24        ECHO                                                     $4
         25      > RETURN                                                   1

Function array_key_match:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4ZlSY
function name:  array_key_match
number of ops:  18
compiled vars:  !0 = $target, !1 = $match, !2 = $targetKeys, !3 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !2, $4
    5     6        INIT_FCALL                                               'array_diff'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !3, $6
    6    11        INIT_FCALL                                               'array_diff'
         12        SEND_VAR                                                 !3
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $8      
         15        IS_EQUAL                                         ~9      !3, $8
         16      > RETURN                                                   ~9
    7    17*     > RETURN                                                   null

End of function array_key_match

Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4ZlSY
function name:  test
number of ops:  28
compiled vars:  !0 = $target, !1 = $match, !2 = $expect
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   13     3        INIT_FCALL                                               'sprintf'
   14     4        SEND_VAL                                                 'Target+%25s%2C+Match+%25s%3A+%25s%0A'
   15     5        INIT_FCALL                                               'var_export'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 <true>
          8        DO_ICALL                                         $3      
          9        SEND_VAR                                                 $3
   16    10        INIT_FCALL                                               'var_export'
         11        SEND_VAR                                                 !1
         12        SEND_VAL                                                 <true>
         13        DO_ICALL                                         $4      
         14        SEND_VAR                                                 $4
   17    15        INIT_FCALL                                               'array_key_match'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        DO_FCALL                                      0  $5      
         19        IS_EQUAL                                                 !2, $5
         20      > JMPZ                                                     ~6, ->23
   18    21    >   QM_ASSIGN                                        ~7      'true'
         22      > JMP                                                      ->24
   19    23    >   QM_ASSIGN                                        ~7      'false'
         24    >   SEND_VAL                                                 ~7
         25        DO_ICALL                                         $8      
         26      > RETURN                                                   $8
   21    27*     > RETURN                                                   null

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.79 ms | 1403 KiB | 27 Q