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)); } function test($target, $match, $expect) { return preg_replace('/\n/', '', sprintf( "Target %s, Match %s: %s", print_r($target, true), print_r($match, true), (array_key_match($target, $match) == $expect) ? 'true' : 'false' )) . "\n"; } 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/qfMEe
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'test'
          1        SEND_VAL                                                 <array>
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <true>
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
   21     6        INIT_FCALL                                               'test'
          7        SEND_VAL                                                 <array>
          8        SEND_VAL                                                 <array>
          9        SEND_VAL                                                 <true>
         10        DO_FCALL                                      0  $1      
         11        ECHO                                                     $1
   22    12        INIT_FCALL                                               'test'
         13        SEND_VAL                                                 <array>
         14        SEND_VAL                                                 <array>
         15        SEND_VAL                                                 <false>
         16        DO_FCALL                                      0  $2      
         17        ECHO                                                     $2
         18      > RETURN                                                   1

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

End of function test

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.96 ms | 1403 KiB | 27 Q