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_unique($array, SORT_REGULAR); 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 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 81
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 81
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 30, Position 2 = 34
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 42
Branch analysis from position: 35
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 50
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 80
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 80
Branch analysis from position: 50
Branch analysis from position: 42
Branch analysis from position: 34
Branch analysis from position: 81
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 81
Branch analysis from position: 17
filename:       /in/e5Bd7
function name:  (null)
number of ops:  89
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_unique'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        DO_ICALL                                         $12     
          6        ASSIGN                                                   !0, $12
   26     7      > FE_RESET_R                                       $14     !0, ->17
          8    > > FE_FETCH_R                                               $14, !2, ->17
   27     9    >   FETCH_DIM_R                                      ~15     !2, 'id'
         10        FETCH_DIM_R                                      ~17     !2, 'email_adr'
         11        FETCH_DIM_R                                      ~20     !2, 'ad_owner_email'
         12        FETCH_DIM_W                                      $16     !1, ~15
         13        FETCH_DIM_W                                      $18     $16, ~17
         14        ASSIGN_DIM                                               $18
         15        OP_DATA                                                  ~20
   26    16      > JMP                                                      ->8
         17    >   FE_FREE                                                  $14
   31    18      > FE_RESET_R                                       $21     !0, ->81
         19    > > FE_FETCH_R                                       ~22     $21, !2, ->81
         20    >   ASSIGN                                                   !3, ~22
   33    21        FETCH_DIM_R                                      ~24     !2, 'id'
         22        ASSIGN                                                   !4, ~24
   34    23        FETCH_DIM_R                                      ~26     !2, 'ad_owner_email'
         24        ASSIGN                                                   !5, ~26
   35    25        FETCH_DIM_R                                      ~28     !2, 'email_adr'
         26        ASSIGN                                                   !6, ~28
   37    27        FETCH_DIM_IS                                     ~30     !1, !4
         28        ISSET_ISEMPTY_DIM_OBJ                         0  ~31     ~30, !5
         29      > JMPZ_EX                                          ~31     ~31, ->34
   38    30    >   FETCH_DIM_IS                                     ~32     !1, !4
         31        ISSET_ISEMPTY_DIM_OBJ                         1  ~33     ~32, !5
         32        BOOL_NOT                                         ~34     ~33
         33        BOOL                                             ~31     ~34
         34    > > JMPZ_EX                                          ~31     ~31, ->42
   39    35    >   INIT_FCALL                                               'in_array'
         36        SEND_VAR                                                 !6
         37        FETCH_DIM_R                                      ~35     !1, !4
         38        FETCH_DIM_R                                      ~36     ~35, !5
         39        SEND_VAL                                                 ~36
         40        DO_ICALL                                         $37     
         41        BOOL                                             ~31     $37
         42    > > JMPZ_EX                                          ~31     ~31, ->50
   40    43    >   INIT_FCALL                                               'in_array'
         44        SEND_VAR                                                 !5
         45        FETCH_DIM_R                                      ~38     !1, !4
         46        FETCH_DIM_R                                      ~39     ~38, !6
         47        SEND_VAL                                                 ~39
         48        DO_ICALL                                         $40     
         49        BOOL                                             ~31     $40
         50    > > JMPZ                                                     ~31, ->80
   44    51    >   INIT_FCALL                                               'array_search'
         52        SEND_VAR                                                 !6
         53        FETCH_DIM_R                                      ~41     !1, !4
         54        FETCH_DIM_R                                      ~42     ~41, !5
         55        SEND_VAL                                                 ~42
         56        DO_ICALL                                         $43     
         57        ASSIGN                                                   !7, $43
   45    58        INIT_FCALL                                               'array_search'
         59        SEND_VAR                                                 !5
         60        FETCH_DIM_R                                      ~45     !1, !4
         61        FETCH_DIM_R                                      ~46     ~45, !6
         62        SEND_VAL                                                 ~46
         63        DO_ICALL                                         $47     
         64        ASSIGN                                                   !8, $47
   47    65        INIT_FCALL                                               'getindex'
         66        SEND_VAR                                                 !0
         67        INIT_ARRAY                                       ~49     !5, 'a'
         68        ADD_ARRAY_ELEMENT                                ~49     !6, 'b'
         69        ADD_ARRAY_ELEMENT                                ~49     !4, 'c'
         70        SEND_VAL                                                 ~49
         71        DO_FCALL                                      0  $50     
         72        ASSIGN                                                   !9, $50
   49    73        FETCH_DIM_UNSET                                  $52     !1, !4
         74        FETCH_DIM_UNSET                                  $53     $52, !6
         75        UNSET_DIM                                                $53, !8
   50    76        FETCH_DIM_UNSET                                  $54     !1, !4
         77        FETCH_DIM_UNSET                                  $55     $54, !5
         78        UNSET_DIM                                                $55, !7
   51    79        UNSET_DIM                                                !0, !9
   31    80    > > JMP                                                      ->19
         81    >   FE_FREE                                                  $21
   55    82        INIT_FCALL                                               'sort'
         83        SEND_REF                                                 !0
         84        DO_ICALL                                                 
   56    85        INIT_FCALL                                               'print_r'
         86        SEND_VAR                                                 !0
         87        DO_ICALL                                                 
         88      > 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/e5Bd7
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:
157.1 ms | 1030 KiB | 19 Q