3v4l.org

run code in 500+ PHP versions simultaneously
<?php function unique_multidim_array($array, $key) { $temp_array = array(); $i = 0; $key_array = array(); foreach($array as $val) { if (!in_array($val[$key], $key_array)) { $key_array[$i] = $val[$key]; $temp_array[$i] = $val; } $i++; } return $temp_array; } $content = [ [ "id" => 15710, "sale_id" => 6699, "item_id" => 300 ], [ "id" => 15711, "sale_id" => 6699, "item_id" => 300 ] ]; print_r(unique_multidim_array($content,'item_id')); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/v5k1j
function name:  (null)
number of ops:  9
compiled vars:  !0 = $content
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, <array>
   30     1        INIT_FCALL                                                   'print_r'
          2        INIT_FCALL                                                   'unique_multidim_array'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     'item_id'
          5        DO_FCALL                                          0  $2      
          6        SEND_VAR                                                     $2
          7        DO_ICALL                                                     
   32     8      > RETURN                                                       1

Function unique_multidim_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/v5k1j
function name:  unique_multidim_array
number of ops:  21
compiled vars:  !0 = $array, !1 = $key, !2 = $temp_array, !3 = $i, !4 = $key_array, !5 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    3     2        ASSIGN                                                       !2, <array>
    4     3        ASSIGN                                                       !3, 0
    5     4        ASSIGN                                                       !4, <array>
    7     5      > FE_RESET_R                                           $9      !0, ->18
          6    > > FE_FETCH_R                                                   $9, !5, ->18
    8     7    >   FETCH_DIM_R                                          ~10     !5, !1
          8        FRAMELESS_ICALL_2                in_array            ~11     ~10, !4
          9        BOOL_NOT                                             ~12     ~11
         10      > JMPZ                                                         ~12, ->16
    9    11    >   FETCH_DIM_R                                          ~14     !5, !1
         12        ASSIGN_DIM                                                   !4, !3
         13        OP_DATA                                                      ~14
   10    14        ASSIGN_DIM                                                   !2, !3
         15        OP_DATA                                                      !5
   12    16    >   PRE_INC                                                      !3
    7    17      > JMP                                                          ->6
         18    >   FE_FREE                                                      $9
   14    19      > RETURN                                                       !2
   15    20*     > RETURN                                                       null

End of function unique_multidim_array

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
132.02 ms | 481 KiB | 9 Q