3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr1 = [ [ 'email' => 'aa@gmail.com', 'name' => 'John Doe', ], [ 'email' => 'bb@gmail.com', 'name' => 'Johnny Sins', ], [ 'email' => 'cc@gmail.com', 'name' => 'Jose Alvarado', ], ]; $arr2 = [ [ 'email' => 'cc@gmail.com', 'country' => 'Japan', ], [ 'email' => 'cc@gmail.com', 'country' => 'China', ], [ 'email' => 'bb@gmail.com', 'country' => 'Korea', ], ]; $final = []; foreach($arr1 as $key=>$ar){ $data = array_count_values(array_column($arr2,'email')); if(!isset($data[$ar['email']])){ $final[] = $ar; } if(isset($data[$ar['email']]) && $data[$ar['email']] < 2){ $ar['country'] = $arr2[$key]['country']; $final[] = $ar; } } print_r($final);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 35
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 34
Branch analysis from position: 27
Branch analysis from position: 20
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/s7dTO
function name:  (null)
number of ops:  40
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $final, !3 = $ar, !4 = $key, !5 = $data
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   18     1        ASSIGN                                                       !1, <array>
   33     2        ASSIGN                                                       !2, <array>
   35     3      > FE_RESET_R                                           $9      !0, ->35
          4    > > FE_FETCH_R                                           ~10     $9, !3, ->35
          5    >   ASSIGN                                                       !4, ~10
   37     6        INIT_FCALL                                                   'array_count_values'
          7        INIT_FCALL                                                   'array_column'
          8        SEND_VAR                                                     !1
          9        SEND_VAL                                                     'email'
         10        DO_ICALL                                             $12     
         11        SEND_VAR                                                     $12
         12        DO_ICALL                                             $13     
         13        ASSIGN                                                       !5, $13
   39    14        FETCH_DIM_R                                          ~15     !3, 'email'
         15        ISSET_ISEMPTY_DIM_OBJ                             0  ~16     !5, ~15
         16        BOOL_NOT                                             ~17     ~16
         17      > JMPZ                                                         ~17, ->20
   40    18    >   ASSIGN_DIM                                                   !2
         19        OP_DATA                                                      !3
   43    20    >   FETCH_DIM_R                                          ~19     !3, 'email'
         21        ISSET_ISEMPTY_DIM_OBJ                             0  ~20     !5, ~19
         22      > JMPZ_EX                                              ~20     ~20, ->27
         23    >   FETCH_DIM_R                                          ~21     !3, 'email'
         24        FETCH_DIM_R                                          ~22     !5, ~21
         25        IS_SMALLER                                           ~23     ~22, 2
         26        BOOL                                                 ~20     ~23
         27    > > JMPZ                                                         ~20, ->34
   44    28    >   FETCH_DIM_R                                          ~25     !1, !4
         29        FETCH_DIM_R                                          ~26     ~25, 'country'
         30        ASSIGN_DIM                                                   !3, 'country'
         31        OP_DATA                                                      ~26
   45    32        ASSIGN_DIM                                                   !2
         33        OP_DATA                                                      !3
   35    34    > > JMP                                                          ->4
         35    >   FE_FREE                                                      $9
   49    36        INIT_FCALL                                                   'print_r'
         37        SEND_VAR                                                     !2
         38        DO_ICALL                                                     
         39      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
196.42 ms | 1801 KiB | 16 Q