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' ] ]; foreach ($array as $index => $a) { foreach ($array as $v) { if ($v === $a) continue; if (reset($v) === reset($a)) $array[$index]["id"] = "duplicate"; if (next($v) === next($a)) $array[$index]["name"] = "duplicate"; } } $array = array_reduce($array, function($carry, $item) { if (array_key_exists("id", $item) || array_key_exists("name", $item)) { unset($item["id"], $item["name"]); $carry[] = $item; } return $carry; }, []); print_r($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 34
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 34
Branch analysis from position: 3
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 32
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 31
Branch analysis from position: 20
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 32
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/ed6dK
function name:  (null)
number of ops:  46
compiled vars:  !0 = $array, !1 = $a, !2 = $index, !3 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   31     1      > FE_RESET_R                                       $5      !0, ->34
          2    > > FE_FETCH_R                                       ~6      $5, !1, ->34
          3    >   ASSIGN                                                   !2, ~6
   32     4      > FE_RESET_R                                       $8      !0, ->32
          5    > > FE_FETCH_R                                               $8, !3, ->32
   33     6    >   IS_IDENTICAL                                             !3, !1
          7      > JMPZ                                                     ~9, ->9
          8    > > JMP                                                      ->5
   34     9    >   INIT_FCALL                                               'reset'
         10        SEND_REF                                                 !3
         11        DO_ICALL                                         $10     
         12        INIT_FCALL                                               'reset'
         13        SEND_REF                                                 !1
         14        DO_ICALL                                         $11     
         15        IS_IDENTICAL                                             $10, $11
         16      > JMPZ                                                     ~12, ->20
         17    >   FETCH_DIM_W                                      $13     !0, !2
         18        ASSIGN_DIM                                               $13, 'id'
         19        OP_DATA                                                  'duplicate'
   35    20    >   INIT_FCALL                                               'next'
         21        SEND_REF                                                 !3
         22        DO_ICALL                                         $15     
         23        INIT_FCALL                                               'next'
         24        SEND_REF                                                 !1
         25        DO_ICALL                                         $16     
         26        IS_IDENTICAL                                             $15, $16
         27      > JMPZ                                                     ~17, ->31
         28    >   FETCH_DIM_W                                      $18     !0, !2
         29        ASSIGN_DIM                                               $18, 'name'
         30        OP_DATA                                                  'duplicate'
   32    31    > > JMP                                                      ->5
         32    >   FE_FREE                                                  $8
   31    33      > JMP                                                      ->2
         34    >   FE_FREE                                                  $5
   39    35        INIT_FCALL                                               'array_reduce'
         36        SEND_VAR                                                 !0
         37        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fed6dK%3A39%240'
   45    38        SEND_VAL                                                 ~20
         39        SEND_VAL                                                 <array>
         40        DO_ICALL                                         $21     
   39    41        ASSIGN                                                   !0, $21
   47    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !0
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fed6dK%3A39%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
Branch analysis from position: 6
filename:       /in/ed6dK
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   40     2        ARRAY_KEY_EXISTS                                 ~2      'id', !1
          3      > JMPNZ_EX                                         ~2      ~2, ->6
          4    >   ARRAY_KEY_EXISTS                                 ~3      'name', !1
          5        BOOL                                             ~2      ~3
          6    > > JMPZ                                                     ~2, ->11
   41     7    >   UNSET_DIM                                                !1, 'id'
          8        UNSET_DIM                                                !1, 'name'
   42     9        ASSIGN_DIM                                               !0
         10        OP_DATA                                                  !1
   44    11    > > RETURN                                                   !0
   45    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fed6dK%3A39%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.33 ms | 1400 KiB | 21 Q