3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_1 = [ 'id' => '42', 'base_id' => '23', 'role_id' => '1', 'title' => 'Manage Account', 'slug' => 'manage_account', 'parent' => '31', 'order' => '1', 'visibility' => '1' ]; $array_2 = [ 'id' => '42', 'base_id' => '23', 'role_id' => '99999', 'title' => 'Manage Account', 'slug' => 'manage_account', 'parent' => '31', 'order' => '1', 'visibility' => '1' ]; var_dump(array_diff($array_1, $array_2)); // Result (unexpected) // array (size=0) // empty $diff = []; foreach ($array_1 as $key => $value) { if ((string) $array_1[$key] !== (string) $array_2[$key]) { $diff[$key] = $value; } } var_dump($diff); // Result (expected) // array (size=1) // 'role_id' => string '1' (length=1)
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 22
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 22
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/1JggJ
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array_1, !1 = $array_2, !2 = $diff, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   24     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'array_diff'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $7      
          7        SEND_VAR                                                 $7
          8        DO_ICALL                                                 
   29     9        ASSIGN                                                   !2, <array>
   30    10      > FE_RESET_R                                       $10     !0, ->22
         11    > > FE_FETCH_R                                       ~11     $10, !3, ->22
         12    >   ASSIGN                                                   !4, ~11
   31    13        FETCH_DIM_R                                      ~13     !0, !4
         14        CAST                                          6  ~14     ~13
         15        FETCH_DIM_R                                      ~15     !1, !4
         16        CAST                                          6  ~16     ~15
         17        IS_NOT_IDENTICAL                                         ~14, ~16
         18      > JMPZ                                                     ~17, ->21
   32    19    >   ASSIGN_DIM                                               !2, !4
         20        OP_DATA                                                  !3
   30    21    > > JMP                                                      ->11
         22    >   FE_FREE                                                  $10
   36    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
   39    26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.28 ms | 1000 KiB | 15 Q