3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = []; $ar[0]['name'] = 'Ted'; $ar[1]['name'] = 'Red'; $ar[2]['name'] = 'Ted'; $res_ar = []; $ar_names = []; foreach($ar as $ind => $row){ if (in_array($row['name'],$ar_names)){ array_splice($ar,$ind,1); } else { $ar_names[] = $row['name']; $res_ar[] = $row; } } print_r($res_ar);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 33
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/JR52I
function name:  (null)
number of ops:  38
compiled vars:  !0 = $ar, !1 = $res_ar, !2 = $ar_names, !3 = $row, !4 = $ind
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        FETCH_DIM_W                                      $6      !0, 0
          2        ASSIGN_DIM                                               $6, 'name'
          3        OP_DATA                                                  'Ted'
    5     4        FETCH_DIM_W                                      $8      !0, 1
          5        ASSIGN_DIM                                               $8, 'name'
          6        OP_DATA                                                  'Red'
    6     7        FETCH_DIM_W                                      $10     !0, 2
          8        ASSIGN_DIM                                               $10, 'name'
          9        OP_DATA                                                  'Ted'
    8    10        ASSIGN                                                   !1, <array>
    9    11        ASSIGN                                                   !2, <array>
   11    12      > FE_RESET_R                                       $14     !0, ->33
         13    > > FE_FETCH_R                                       ~15     $14, !3, ->33
         14    >   ASSIGN                                                   !4, ~15
   12    15        INIT_FCALL                                               'in_array'
         16        FETCH_DIM_R                                      ~17     !3, 'name'
         17        SEND_VAL                                                 ~17
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $18     
         20      > JMPZ                                                     $18, ->27
   13    21    >   INIT_FCALL                                               'array_splice'
         22        SEND_REF                                                 !0
         23        SEND_VAR                                                 !4
         24        SEND_VAL                                                 1
         25        DO_ICALL                                                 
   12    26      > JMP                                                      ->32
   15    27    >   FETCH_DIM_R                                      ~21     !3, 'name'
         28        ASSIGN_DIM                                               !2
         29        OP_DATA                                                  ~21
   16    30        ASSIGN_DIM                                               !1
         31        OP_DATA                                                  !3
   11    32    > > JMP                                                      ->13
         33    >   FE_FREE                                                  $14
   20    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.59 ms | 1009 KiB | 16 Q