3v4l.org

run code in 300+ PHP versions simultaneously
<?php function hasChanged($array1, $array2) { return ( !empty(array_diff_assoc($array1, $array2)) || !empty(array_diff_assoc($array2, $array1)) ); } echo "Set 1\n"; $array1 = array("a" => "green", "b" => "brown", "c" => "blue"); $array2 = array("a" => "green", "b" => "brown2", "c" => "blue2"); $result = array_diff_assoc($array1, $array2); print_r($result); $result = array_diff_assoc($array2, $array1); print_r($result); var_dump(hasChanged($array1, $array2)); echo "Set 2\n"; $array3 = array("a" => "green", "b" => "brown", "c" => "blue"); $array4 = array("a" => "green", "b" => "brown", "c" => "blue", "e" => "bluee"); $result2 = array_diff_assoc($array3, $array4); print_r($result2); $result2 = array_diff_assoc($array4, $array3); print_r($result2); var_dump(hasChanged($array3, $array4)); echo "Set 3\n"; $array5 = array("a" => "green", "b" => "brown", "c" => "blue"); $array6 = array("a" => "green", "b" => "brown", "c" => "blue"); $result3 = array_diff_assoc($array5, $array6); print_r($result3); $result3 = array_diff_assoc($array6, $array5); print_r($result3); var_dump(hasChanged($array5, $array6));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vGXX1
function name:  (null)
number of ops:  79
compiled vars:  !0 = $array1, !1 = $array2, !2 = $result, !3 = $array3, !4 = $array4, !5 = $result2, !6 = $array5, !7 = $array6, !8 = $result3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'Set+1%0A'
   10     1        ASSIGN                                                   !0, <array>
   11     2        ASSIGN                                                   !1, <array>
   12     3        INIT_FCALL                                               'array_diff_assoc'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $11     
          7        ASSIGN                                                   !2, $11
   13     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
   14    11        INIT_FCALL                                               'array_diff_assoc'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !2, $14
   15    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   16    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'haschanged'
         21        SEND_VAR                                                 !0
         22        SEND_VAR                                                 !1
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR                                                 $17
         25        DO_ICALL                                                 
   18    26        ECHO                                                     'Set+2%0A'
   19    27        ASSIGN                                                   !3, <array>
   20    28        ASSIGN                                                   !4, <array>
   21    29        INIT_FCALL                                               'array_diff_assoc'
         30        SEND_VAR                                                 !3
         31        SEND_VAR                                                 !4
         32        DO_ICALL                                         $21     
         33        ASSIGN                                                   !5, $21
   22    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !5
         36        DO_ICALL                                                 
   23    37        INIT_FCALL                                               'array_diff_assoc'
         38        SEND_VAR                                                 !4
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                         $24     
         41        ASSIGN                                                   !5, $24
   24    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !5
         44        DO_ICALL                                                 
   25    45        INIT_FCALL                                               'var_dump'
         46        INIT_FCALL                                               'haschanged'
         47        SEND_VAR                                                 !3
         48        SEND_VAR                                                 !4
         49        DO_FCALL                                      0  $27     
         50        SEND_VAR                                                 $27
         51        DO_ICALL                                                 
   27    52        ECHO                                                     'Set+3%0A'
   28    53        ASSIGN                                                   !6, <array>
   29    54        ASSIGN                                                   !7, <array>
   30    55        INIT_FCALL                                               'array_diff_assoc'
         56        SEND_VAR                                                 !6
         57        SEND_VAR                                                 !7
         58        DO_ICALL                                         $31     
         59        ASSIGN                                                   !8, $31
   31    60        INIT_FCALL                                               'print_r'
         61        SEND_VAR                                                 !8
         62        DO_ICALL                                                 
   32    63        INIT_FCALL                                               'array_diff_assoc'
         64        SEND_VAR                                                 !7
         65        SEND_VAR                                                 !6
         66        DO_ICALL                                         $34     
         67        ASSIGN                                                   !8, $34
   33    68        INIT_FCALL                                               'print_r'
         69        SEND_VAR                                                 !8
         70        DO_ICALL                                                 
   34    71        INIT_FCALL                                               'var_dump'
         72        INIT_FCALL                                               'haschanged'
         73        SEND_VAR                                                 !6
         74        SEND_VAR                                                 !7
         75        DO_FCALL                                      0  $37     
         76        SEND_VAR                                                 $37
         77        DO_ICALL                                                 
         78      > RETURN                                                   1

Function haschanged:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/vGXX1
function name:  hasChanged
number of ops:  18
compiled vars:  !0 = $array1, !1 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'array_diff_assoc'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6        BOOL_NOT                                         ~3      $2
          7        BOOL_NOT                                         ~4      ~3
          8      > JMPNZ_EX                                         ~4      ~4, ->16
    5     9    >   INIT_FCALL                                               'array_diff_assoc'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        BOOL_NOT                                         ~6      $5
         14        BOOL_NOT                                         ~7      ~6
         15        BOOL                                             ~4      ~7
         16    > > RETURN                                                   ~4
    7    17*     > RETURN                                                   null

End of function haschanged

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.86 ms | 1018 KiB | 19 Q