3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['id[0]' => 'BX-78', 'Name[0]' => 'XXX', 'Address[0]' => 'YUUSATD'], ['id[1]' => 'BX-79', 'Name[1]' => 'YYY', 'Address[1]' => 'DHJSHDJGY'], ['id[2]' => 'BX-80', 'Name[2]' => 'ZZZ', 'Address[2]' => 'DDSDSDA'], ['id[3]' => 'BX-78', 'Name[3]' => 'AAA', 'Address[3]' => 'FSDSDS'], ['id[4]' => 'BX-81', 'Name[4]' => 'XXX', 'Address[4]' => 'DSDSDSD'] ]; $dupes = []; $current = []; foreach ($array as $index => $entry) { $idKey = "id[$index]"; $nameKey = "Name[$index]"; if (array_key_exists($entry[$idKey], $current)) { $dupes[] = [$entry, $current[$entry[$idKey]]]; } elseif (array_key_exists($entry[$nameKey], $current)) { $dupes[] = [$entry, $current[$entry[$nameKey]]]; } else { $current[$entry[$idKey]] = $current[$entry[$nameKey]] = $entry; } } print_r($dupes);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 41
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 41
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/JAtNU
function name:  (null)
number of ops:  46
compiled vars:  !0 = $array, !1 = $dupes, !2 = $current, !3 = $entry, !4 = $index, !5 = $idKey, !6 = $nameKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, <array>
   12     2        ASSIGN                                                   !2, <array>
   14     3      > FE_RESET_R                                       $10     !0, ->41
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->41
          5    >   ASSIGN                                                   !4, ~11
   15     6        ROPE_INIT                                     3  ~14     'id%5B'
          7        ROPE_ADD                                      1  ~14     ~14, !4
          8        ROPE_END                                      2  ~13     ~14, '%5D'
          9        ASSIGN                                                   !5, ~13
   16    10        ROPE_INIT                                     3  ~18     'Name%5B'
         11        ROPE_ADD                                      1  ~18     ~18, !4
         12        ROPE_END                                      2  ~17     ~18, '%5D'
         13        ASSIGN                                                   !6, ~17
   17    14        FETCH_DIM_R                                      ~21     !3, !5
         15        ARRAY_KEY_EXISTS                                         ~21, !2
         16      > JMPZ                                                     ~22, ->24
   18    17    >   INIT_ARRAY                                       ~24     !3
         18        FETCH_DIM_R                                      ~25     !3, !5
         19        FETCH_DIM_R                                      ~26     !2, ~25
         20        ADD_ARRAY_ELEMENT                                ~24     ~26
         21        ASSIGN_DIM                                               !1
         22        OP_DATA                                                  ~24
         23      > JMP                                                      ->40
   20    24    >   FETCH_DIM_R                                      ~27     !3, !6
         25        ARRAY_KEY_EXISTS                                         ~27, !2
         26      > JMPZ                                                     ~28, ->34
   21    27    >   INIT_ARRAY                                       ~30     !3
         28        FETCH_DIM_R                                      ~31     !3, !6
         29        FETCH_DIM_R                                      ~32     !2, ~31
         30        ADD_ARRAY_ELEMENT                                ~30     ~32
         31        ASSIGN_DIM                                               !1
         32        OP_DATA                                                  ~30
         33      > JMP                                                      ->40
   24    34    >   FETCH_DIM_R                                      ~33     !3, !5
         35        FETCH_DIM_R                                      ~35     !3, !6
         36        ASSIGN_DIM                                       ~36     !2, ~35
         37        OP_DATA                                                  !3
         38        ASSIGN_DIM                                               !2, ~33
         39        OP_DATA                                                  ~36
   14    40    > > JMP                                                      ->4
         41    >   FE_FREE                                                  $10
   28    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !1
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.81 ms | 1400 KiB | 15 Q