3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ('1' => (object)array( 'id' => 225, 'user_id' => 1, 'name' => 'Blue Quilted Leather Jacket by Minusey - $499' ), '2' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ), '3' => (object)array( 'id' => 222, 'user_id' => 1, 'name' => 'Darling New Bathtub by Duravit - $6300' ) ); //print_r(array_column((array)$array, 'id')); $array = array_map(function($x){return (array)$x;}, $array); $ids = array_unique(array_column($array, 'id')); $array = array_filter($array, function($x) use ($ids){return in_array($x['id'], $ids);}); print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQOin
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array, !1 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~2      <array>
          1        INIT_ARRAY                                       ~3      ~2, 1
   10     2        CAST                                          8  ~4      <array>
          3        ADD_ARRAY_ELEMENT                                ~3      ~4, 2
   16     4        CAST                                          8  ~5      <array>
          5        ADD_ARRAY_ELEMENT                                ~3      ~5, 3
    3     6        ASSIGN                                                   !0, ~3
   23     7        INIT_FCALL                                               'array_map'
          8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcQOin%3A23%240'
          9        SEND_VAL                                                 ~7
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !0, $8
   24    13        INIT_FCALL                                               'array_unique'
         14        INIT_FCALL                                               'array_column'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 'id'
         17        DO_ICALL                                         $10     
         18        SEND_VAR                                                 $10
         19        DO_ICALL                                         $11     
         20        ASSIGN                                                   !1, $11
   25    21        INIT_FCALL                                               'array_filter'
         22        SEND_VAR                                                 !0
         23        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcQOin%3A25%241'
         24        BIND_LEXICAL                                             ~13, !1
         25        SEND_VAL                                                 ~13
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !0, $14
   26    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !0
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FcQOin%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQOin
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        CAST                                          7  ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcQOin%3A23%240

Function %00%7Bclosure%7D%2Fin%2FcQOin%3A25%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cQOin
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $x, !1 = $ids
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'id'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
          8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FcQOin%3A25%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.7 ms | 1400 KiB | 25 Q