3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_diff_assoc_recursive($array1, $array2) { foreach($array1 as $key => $value) { if(is_array($value)) { if(!isset($array2[$key])) { $difference[$key] = $value; } elseif(!is_array($array2[$key])) { $difference[$key] = $value; } else { $new_diff = array_diff_assoc_recursive($value, $array2[$key]); if($new_diff != FALSE) { $difference[$key] = $new_diff; } } } elseif(!array_key_exists($key, $array2) || $array2[$key] != $value) { $difference[$key] = $value; } } return !isset($difference) ? 0 : $difference; } $array1 = array("a" => "green", "red","b" => "brown",1,"d"=>1); $array2 = array("a" => "green","b" => "brown", "red",true,"d"=>true); $result = array_diff_assoc($array1, $array2); print_r($result); $array1 = array("a" => "green", "red","b" => "brown",1,"d"=>array("a" => "green", "red","b" => "brown",1,"d"=>2)); $array2 = array("a" => "green","b" => "brown", "red",true,"d"=>array("a" => "green","b" => "brown", "red",true,"d"=>true)); $resultRec = array_diff_assoc_recursive($array1,$array2); print_r($resultRec); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7VK6U
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array1, !1 = $array2, !2 = $result, !3 = $resultRec
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   ASSIGN                                                   !0, <array>
   37     1        ASSIGN                                                   !1, <array>
   38     2        INIT_FCALL                                               'array_diff_assoc'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   39     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   41    10        ASSIGN                                                   !0, <array>
   42    11        ASSIGN                                                   !1, <array>
   45    12        INIT_FCALL                                               'array_diff_assoc_recursive'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_FCALL                                      0  $11     
         16        ASSIGN                                                   !3, $11
   46    17        INIT_FCALL                                               'print_r'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                                 
   48    20      > RETURN                                                   1

Function array_diff_assoc_recursive:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 42
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 42
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 31
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 31
Branch analysis from position: 32
2 jumps found. (Code = 47) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 41
Branch analysis from position: 38
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/7VK6U
function name:  array_diff_assoc_recursive
number of ops:  51
compiled vars:  !0 = $array1, !1 = $array2, !2 = $value, !3 = $key, !4 = $difference, !5 = $new_diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2      > FE_RESET_R                                       $6      !0, ->42
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->42
          4    >   ASSIGN                                                   !3, ~7
    7     5        TYPE_CHECK                                  128          !2
          6      > JMPZ                                                     ~9, ->32
    9     7    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~10     !1, !3
          8        BOOL_NOT                                         ~11     ~10
          9      > JMPZ                                                     ~11, ->13
   11    10    >   ASSIGN_DIM                                               !4, !3
         11        OP_DATA                                                  !2
         12      > JMP                                                      ->31
   13    13    >   FETCH_DIM_R                                      ~13     !1, !3
         14        TYPE_CHECK                                  128  ~14     ~13
         15        BOOL_NOT                                         ~15     ~14
         16      > JMPZ                                                     ~15, ->20
   15    17    >   ASSIGN_DIM                                               !4, !3
         18        OP_DATA                                                  !2
         19      > JMP                                                      ->31
   19    20    >   INIT_FCALL_BY_NAME                                       'array_diff_assoc_recursive'
         21        SEND_VAR_EX                                              !2
         22        CHECK_FUNC_ARG                                           
         23        FETCH_DIM_FUNC_ARG                               $17     !1, !3
         24        SEND_FUNC_ARG                                            $17
         25        DO_FCALL                                      0  $18     
         26        ASSIGN                                                   !5, $18
   20    27        BOOL                                             ~20     !5
         28      > JMPZ                                                     ~20, ->31
   22    29    >   ASSIGN_DIM                                               !4, !3
         30        OP_DATA                                                  !5
         31    > > JMP                                                      ->41
   26    32    >   ARRAY_KEY_EXISTS                                 ~22     !3, !1
         33        BOOL_NOT                                         ~23     ~22
         34      > JMPNZ_EX                                         ~23     ~23, ->38
         35    >   FETCH_DIM_R                                      ~24     !1, !3
         36        IS_NOT_EQUAL                                     ~25     !2, ~24
         37        BOOL                                             ~23     ~25
         38    > > JMPZ                                                     ~23, ->41
   28    39    >   ASSIGN_DIM                                               !4, !3
         40        OP_DATA                                                  !2
    5    41    > > JMP                                                      ->3
         42    >   FE_FREE                                                  $6
   31    43        ISSET_ISEMPTY_CV                                 ~27     !4
         44        BOOL_NOT                                         ~28     ~27
         45      > JMPZ                                                     ~28, ->48
         46    >   QM_ASSIGN                                        ~29     0
         47      > JMP                                                      ->49
         48    >   QM_ASSIGN                                        ~29     !4
         49    > > RETURN                                                   ~29
   32    50*     > RETURN                                                   null

End of function array_diff_assoc_recursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.35 ms | 1407 KiB | 18 Q