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

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

End of function getindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.34 ms | 1024 KiB | 18 Q