3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ['keepThis', 'remove', false, 'keep', 'save', 'delete']; $array2 = ['hangOnto', 'remove', null, 'retain', 'keep', 'delete', 'extra']; $clean1 = $array1; $clean2 = array_diff_ukey( $array2, $array1, // Need to have "&" so the values get set. function($a, $b) use (&$clean1, $array1, $array2) { echo "a = $a, b = $b\n"; // Use isset() just in case keys are not identical // or arrays are not the same length. if (isset($array2[$b]) && $array2[$b] === $array1[$b]) { unset($clean1[$b]); } return strcmp($array2[$a], $array1[$b]); }); print_r($clean1); print_r($clean2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/V5gYq
function name:  (null)
number of ops:  20
compiled vars:  !0 = $array1, !1 = $array2, !2 = $clean1, !3 = $clean2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, !0
    8     3        INIT_FCALL                                               'array_diff_ukey'
    9     4        SEND_VAR                                                 !1
   10     5        SEND_VAR                                                 !0
   12     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FV5gYq%3A12%240'
          7        BIND_LEXICAL                                             ~7, !2
          8        BIND_LEXICAL                                             ~7, !0
          9        BIND_LEXICAL                                             ~7, !1
   22    10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
    8    12        ASSIGN                                                   !3, $8
   24    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
   25    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !3
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FV5gYq%3A12%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
Branch analysis from position: 17
filename:       /in/V5gYq
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $a, !1 = $b, !2 = $clean1, !3 = $array1, !4 = $array2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        BIND_STATIC                                              !3
          4        BIND_STATIC                                              !4
   13     5        ROPE_INIT                                     5  ~6      'a+%3D+'
          6        ROPE_ADD                                      1  ~6      ~6, !0
          7        ROPE_ADD                                      2  ~6      ~6, '%2C+b+%3D+'
          8        ROPE_ADD                                      3  ~6      ~6, !1
          9        ROPE_END                                      4  ~5      ~6, '%0A'
         10        ECHO                                                     ~5
   16    11        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !4, !1
         12      > JMPZ_EX                                          ~9      ~9, ->17
         13    >   FETCH_DIM_R                                      ~10     !4, !1
         14        FETCH_DIM_R                                      ~11     !3, !1
         15        IS_IDENTICAL                                     ~12     ~10, ~11
         16        BOOL                                             ~9      ~12
         17    > > JMPZ                                                     ~9, ->19
   17    18    >   UNSET_DIM                                                !2, !1
   20    19    >   INIT_FCALL                                               'strcmp'
         20        FETCH_DIM_R                                      ~13     !4, !0
         21        SEND_VAL                                                 ~13
         22        FETCH_DIM_R                                      ~14     !3, !1
         23        SEND_VAL                                                 ~14
         24        DO_ICALL                                         $15     
         25      > RETURN                                                   $15
   22    26*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FV5gYq%3A12%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.29 ms | 1400 KiB | 19 Q