3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [["id"=>"111","email_adr"=>"AAA","ad_owner_email"=>"BBB"], ["id"=>"111","email_adr"=>"BBB","ad_owner_email"=>"CCC"], ["id"=>"111","email_adr"=>"BBB","ad_owner_email"=>"AAA"], //<--discarded ["id"=>"500","email_adr"=>"QQQ","ad_owner_email"=>"PPP"], ["id"=>"500","email_adr"=>"PPP","ad_owner_email"=>"QQQ"], //<--discarded ["id"=>"999","email_adr"=>"PPP","ad_owner_email"=>"QQQ"], //<-saved because id=999 ["id"=>"888","email_adr"=>"PPP","ad_owner_email"=>"QQQ"], ["id"=>"888","email_adr"=>"PPP","ad_owner_email"=>"QQQ"], ["id"=>"888","email_adr"=>"QQQ","ad_owner_email"=>"PPP"], //<--discarded ]; $tmp1 = []; $array = array_map("unserialize", array_unique(array_map("serialize", $array))); function getIndex($data,$ne){ foreach($data as $key=>$val){ if ($val['id'] === $ne['c'] && $val['email_adr'] === $ne['a'] && $val['ad_owner_email'] === $ne['b']) return $key; } return -1; } foreach($array as $record){ $tmp1[$record['id']][$record['email_adr']][] = $record['ad_owner_email']; } // print_r($tmp1); foreach($array as $ind=>$record){ $id = $record['id']; $em_owner = $record['ad_owner_email']; $em_adr = $record['email_adr']; if (isset( $tmp1[$id][$em_owner] ) && !empty( $tmp1[$id][$em_owner] ) && in_array( $em_adr, $tmp1[$id][$em_owner] ) && in_array( $em_owner, $tmp1[$id][$em_adr] ) ) { $tm1 = array_search($em_adr, $tmp1[$id][$em_owner]); $tm2 = array_search($em_owner, $tmp1[$id][$em_adr]); $in = getIndex($array, ['a'=>$em_owner, 'b'=>$em_adr, 'c'=>$id]); unset( $tmp1[$id][$em_adr][$tm2] ); unset( $tmp1[$id][$em_owner][$tm1] ); unset( $array[$in] ); } } sort($array); print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 26, Position 2 = 88
Branch analysis from position: 26
2 jumps found. (Code = 78) Position 1 = 27, Position 2 = 88
Branch analysis from position: 27
2 jumps found. (Code = 46) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
2 jumps found. (Code = 46) Position 1 = 42, Position 2 = 49
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 57
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 87
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 87
Branch analysis from position: 57
Branch analysis from position: 49
Branch analysis from position: 41
Branch analysis from position: 88
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 88
Branch analysis from position: 24
filename:       /in/iijMT
function name:  (null)
number of ops:  96
compiled vars:  !0 = $array, !1 = $tmp1, !2 = $record, !3 = $ind, !4 = $id, !5 = $em_owner, !6 = $em_adr, !7 = $tm1, !8 = $tm2, !9 = $in
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'array_map'
          3        SEND_VAL                                                 'unserialize'
          4        INIT_FCALL                                               'array_unique'
          5        INIT_FCALL                                               'array_map'
          6        SEND_VAL                                                 'serialize'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $12     
          9        SEND_VAR                                                 $12
         10        DO_ICALL                                         $13     
         11        SEND_VAR                                                 $13
         12        DO_ICALL                                         $14     
         13        ASSIGN                                                   !0, $14
   26    14      > FE_RESET_R                                       $16     !0, ->24
         15    > > FE_FETCH_R                                               $16, !2, ->24
   27    16    >   FETCH_DIM_R                                      ~17     !2, 'id'
         17        FETCH_DIM_R                                      ~19     !2, 'email_adr'
         18        FETCH_DIM_R                                      ~22     !2, 'ad_owner_email'
         19        FETCH_DIM_W                                      $18     !1, ~17
         20        FETCH_DIM_W                                      $20     $18, ~19
         21        ASSIGN_DIM                                               $20
         22        OP_DATA                                                  ~22
   26    23      > JMP                                                      ->15
         24    >   FE_FREE                                                  $16
   31    25      > FE_RESET_R                                       $23     !0, ->88
         26    > > FE_FETCH_R                                       ~24     $23, !2, ->88
         27    >   ASSIGN                                                   !3, ~24
   33    28        FETCH_DIM_R                                      ~26     !2, 'id'
         29        ASSIGN                                                   !4, ~26
   34    30        FETCH_DIM_R                                      ~28     !2, 'ad_owner_email'
         31        ASSIGN                                                   !5, ~28
   35    32        FETCH_DIM_R                                      ~30     !2, 'email_adr'
         33        ASSIGN                                                   !6, ~30
   37    34        FETCH_DIM_IS                                     ~32     !1, !4
         35        ISSET_ISEMPTY_DIM_OBJ                         0  ~33     ~32, !5
         36      > JMPZ_EX                                          ~33     ~33, ->41
   38    37    >   FETCH_DIM_IS                                     ~34     !1, !4
         38        ISSET_ISEMPTY_DIM_OBJ                         1  ~35     ~34, !5
         39        BOOL_NOT                                         ~36     ~35
         40        BOOL                                             ~33     ~36
         41    > > JMPZ_EX                                          ~33     ~33, ->49
   39    42    >   INIT_FCALL                                               'in_array'
         43        SEND_VAR                                                 !6
         44        FETCH_DIM_R                                      ~37     !1, !4
         45        FETCH_DIM_R                                      ~38     ~37, !5
         46        SEND_VAL                                                 ~38
         47        DO_ICALL                                         $39     
         48        BOOL                                             ~33     $39
         49    > > JMPZ_EX                                          ~33     ~33, ->57
   40    50    >   INIT_FCALL                                               'in_array'
         51        SEND_VAR                                                 !5
         52        FETCH_DIM_R                                      ~40     !1, !4
         53        FETCH_DIM_R                                      ~41     ~40, !6
         54        SEND_VAL                                                 ~41
         55        DO_ICALL                                         $42     
         56        BOOL                                             ~33     $42
         57    > > JMPZ                                                     ~33, ->87
   44    58    >   INIT_FCALL                                               'array_search'
         59        SEND_VAR                                                 !6
         60        FETCH_DIM_R                                      ~43     !1, !4
         61        FETCH_DIM_R                                      ~44     ~43, !5
         62        SEND_VAL                                                 ~44
         63        DO_ICALL                                         $45     
         64        ASSIGN                                                   !7, $45
   45    65        INIT_FCALL                                               'array_search'
         66        SEND_VAR                                                 !5
         67        FETCH_DIM_R                                      ~47     !1, !4
         68        FETCH_DIM_R                                      ~48     ~47, !6
         69        SEND_VAL                                                 ~48
         70        DO_ICALL                                         $49     
         71        ASSIGN                                                   !8, $49
   47    72        INIT_FCALL                                               'getindex'
         73        SEND_VAR                                                 !0
         74        INIT_ARRAY                                       ~51     !5, 'a'
         75        ADD_ARRAY_ELEMENT                                ~51     !6, 'b'
         76        ADD_ARRAY_ELEMENT                                ~51     !4, 'c'
         77        SEND_VAL                                                 ~51
         78        DO_FCALL                                      0  $52     
         79        ASSIGN                                                   !9, $52
   49    80        FETCH_DIM_UNSET                                  $54     !1, !4
         81        FETCH_DIM_UNSET                                  $55     $54, !6
         82        UNSET_DIM                                                $55, !8
   50    83        FETCH_DIM_UNSET                                  $56     !1, !4
         84        FETCH_DIM_UNSET                                  $57     $56, !5
         85        UNSET_DIM                                                $57, !7
   51    86        UNSET_DIM                                                !0, !9
   31    87    > > JMP                                                      ->26
         88    >   FE_FREE                                                  $23
   55    89        INIT_FCALL                                               'sort'
         90        SEND_REF                                                 !0
         91        DO_ICALL                                                 
   56    92        INIT_FCALL                                               'print_r'
         93        SEND_VAR                                                 !0
         94        DO_ICALL                                                 
         95      > RETURN                                                   1

Function getindex:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
Branch analysis from position: 13
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/iijMT
function name:  getIndex
number of ops:  25
compiled vars:  !0 = $data, !1 = $ne, !2 = $val, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2      > FE_RESET_R                                       $4      !0, ->22
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->22
          4    >   ASSIGN                                                   !3, ~5
   21     5        FETCH_DIM_R                                      ~7      !2, 'id'
          6        FETCH_DIM_R                                      ~8      !1, 'c'
          7        IS_IDENTICAL                                     ~9      ~7, ~8
          8      > JMPZ_EX                                          ~9      ~9, ->13
          9    >   FETCH_DIM_R                                      ~10     !2, 'email_adr'
         10        FETCH_DIM_R                                      ~11     !1, 'a'
         11        IS_IDENTICAL                                     ~12     ~10, ~11
         12        BOOL                                             ~9      ~12
         13    > > JMPZ_EX                                          ~9      ~9, ->18
         14    >   FETCH_DIM_R                                      ~13     !2, 'ad_owner_email'
         15        FETCH_DIM_R                                      ~14     !1, 'b'
         16        IS_IDENTICAL                                     ~15     ~13, ~14
         17        BOOL                                             ~9      ~15
         18    > > JMPZ                                                     ~9, ->21
         19    >   FE_FREE                                                  $4
         20      > RETURN                                                   !3
   20    21    > > JMP                                                      ->3
         22    >   FE_FREE                                                  $4
   23    23      > RETURN                                                   -1
   24    24*     > RETURN                                                   null

End of function getindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
259.14 ms | 1031 KiB | 20 Q