3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('status'=>'OK','Productname'=>'test1'), array('status'=>'OK','Productname'=>'test1'), array('status'=>'OK','Productname'=>'test2'), array('status'=>'OK','Productname'=>'test2') ); $notToDuplicate = array('test2'); $newArray = array_unique($arr, SORT_REGULAR); print_r($newArray); foreach($arr as $key => &$val) { if(!in_array($val['Productname'],$arr)) { foreach($newArray as $v) { if($v !== $val) { $newArray[] = $val; } } } } print_r($newArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 11, Position 2 = 29
Branch analysis from position: 11
2 jumps found. (Code = 126) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 78) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
Branch analysis from position: 26
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/Q5FFP
function name:  (null)
number of ops:  34
compiled vars:  !0 = $arr, !1 = $notToDuplicate, !2 = $newArray, !3 = $val, !4 = $key, !5 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'array_unique'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
   13     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   15    10      > FE_RESET_RW                                      $11     !0, ->29
         11    > > FE_FETCH_RW                                      ~12     $11, !3, ->29
         12    >   ASSIGN                                                   !4, ~12
   16    13        INIT_FCALL                                               'in_array'
         14        FETCH_DIM_R                                      ~14     !3, 'Productname'
         15        SEND_VAL                                                 ~14
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $15     
         18        BOOL_NOT                                         ~16     $15
         19      > JMPZ                                                     ~16, ->28
   17    20    > > FE_RESET_R                                       $17     !2, ->27
         21    > > FE_FETCH_R                                               $17, !5, ->27
   18    22    >   IS_NOT_IDENTICAL                                         !5, !3
         23      > JMPZ                                                     ~18, ->26
   19    24    >   ASSIGN_DIM                                               !2
         25        OP_DATA                                                  !3
   17    26    > > JMP                                                      ->21
         27    >   FE_FREE                                                  $17
   15    28    > > JMP                                                      ->11
         29    >   FE_FREE                                                  $11
   25    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.54 ms | 1392 KiB | 19 Q