3v4l.org

run code in 500+ PHP versions simultaneously
<?php $products = [ (object)["item_id" => "89", "name" => "Confiture de Myrtilles", "product_id" => "737", "meta_key" => "vmm_warehouse_sg_10783", "meta_value" => "0" ], (object)["item_id" => "89", "name" => "Confiture de Myrtilles", "product_id" => "737", "meta_key" => "vmm_warehouse_sg_10782", "meta_value" => "0" ] ]; $result = (object)[]; foreach($products as $product) { if (!isset($result->{$product->item_id})) { $result->{$product->item_id} = (object)[]; } $result->{$product->item_id}->{$product->meta_key} = $product->meta_value; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 17
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/NOioC
function name:  (null)
number of ops:  29
compiled vars:  !0 = $products, !1 = $result, !2 = $product
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   CAST                                              8  ~3      <array>
          1        INIT_ARRAY                                           ~4      ~3
          2        CAST                                              8  ~5      <array>
          3        ADD_ARRAY_ELEMENT                                    ~4      ~5
    2     4        ASSIGN                                                       !0, ~4
   16     5        CAST                                              8  ~7      <array>
          6        ASSIGN                                                       !1, ~7
   17     7      > FE_RESET_R                                           $9      !0, ->24
          8    > > FE_FETCH_R                                                   $9, !2, ->24
   18     9    >   FETCH_OBJ_R                                          ~10     !2, 'item_id'
         10        ISSET_ISEMPTY_PROP_OBJ                               ~11     !1, ~10
         11        BOOL_NOT                                             ~12     ~11
         12      > JMPZ                                                         ~12, ->17
   19    13    >   FETCH_OBJ_R                                          ~13     !2, 'item_id'
         14        CAST                                              8  ~15     <array>
         15        ASSIGN_OBJ                                                   !1, ~13
         16        OP_DATA                                                      ~15
   21    17    >   FETCH_OBJ_R                                          ~16     !2, 'item_id'
         18        FETCH_OBJ_R                                          ~18     !2, 'meta_key'
         19        FETCH_OBJ_R                                          ~20     !2, 'meta_value'
         20        FETCH_OBJ_W                                          $17     !1, ~16
         21        ASSIGN_OBJ                                                   $17, ~18
         22        OP_DATA                                                      ~20
   17    23      > JMP                                                          ->8
         24    >   FE_FREE                                                      $9
   24    25        INIT_FCALL                                                   'var_export'
         26        SEND_VAR                                                     !1
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
177.82 ms | 2073 KiB | 14 Q