3v4l.org

run code in 300+ 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 = 21
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 21
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 19
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/v5k1j
function name:  unique_multidim_array
number of ops:  24
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, ->21
          6    > > FE_FETCH_R                                               $9, !5, ->21
    8     7    >   INIT_FCALL                                               'in_array'
          8        FETCH_DIM_R                                      ~10     !5, !1
          9        SEND_VAL                                                 ~10
         10        SEND_VAR                                                 !4
         11        DO_ICALL                                         $11     
         12        BOOL_NOT                                         ~12     $11
         13      > JMPZ                                                     ~12, ->19
    9    14    >   FETCH_DIM_R                                      ~14     !5, !1
         15        ASSIGN_DIM                                               !4, !3
         16        OP_DATA                                                  ~14
   10    17        ASSIGN_DIM                                               !2, !3
         18        OP_DATA                                                  !5
   12    19    >   PRE_INC                                                  !3
    7    20      > JMP                                                      ->6
         21    >   FE_FREE                                                  $9
   14    22      > RETURN                                                   !2
   15    23*     > RETURN                                                   null

End of function unique_multidim_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147 ms | 1015 KiB | 16 Q