3v4l.org

run code in 300+ PHP versions simultaneously
<?php $poorly_merged = [ (object)["id" => "5", "unit" => 1], (object)["id" => "3", "text" => "three"], (object)["id" => "1", "text" => "one"], (object)["id" => "2", "text" => "two"], (object)["id" => "4", "text" => "four"], (object)["id" => "5", "text" => "five"], (object)["id" => "3", "unit" => 0], (object)["id" => "1", "unit" => "0"], (object)["id" => "2", "unit" => 0], (object)["id" => "4", "unit" => "0"] ]; $output = []; foreach ($poorly_merged as $object) { if (!isset($output[$object->id])) { $output[$object->id] = $object; } else { foreach ($object as $property => $value) { $output[$object->id]->{$property} = $value; } } } ksort($output); // optionally order by ids var_export(array_values($output));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 42
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 42
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
2 jumps found. (Code = 78) Position 1 = 34, Position 2 = 40
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 40
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/LLrsk
function name:  (null)
number of ops:  53
compiled vars:  !0 = $poorly_merged, !1 = $output, !2 = $object, !3 = $value, !4 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~5      <array>
          1        INIT_ARRAY                                       ~6      ~5
    5     2        CAST                                          8  ~7      <array>
          3        ADD_ARRAY_ELEMENT                                ~6      ~7
    6     4        CAST                                          8  ~8      <array>
          5        ADD_ARRAY_ELEMENT                                ~6      ~8
    7     6        CAST                                          8  ~9      <array>
          7        ADD_ARRAY_ELEMENT                                ~6      ~9
    8     8        CAST                                          8  ~10     <array>
          9        ADD_ARRAY_ELEMENT                                ~6      ~10
    9    10        CAST                                          8  ~11     <array>
         11        ADD_ARRAY_ELEMENT                                ~6      ~11
   10    12        CAST                                          8  ~12     <array>
         13        ADD_ARRAY_ELEMENT                                ~6      ~12
   11    14        CAST                                          8  ~13     <array>
         15        ADD_ARRAY_ELEMENT                                ~6      ~13
   12    16        CAST                                          8  ~14     <array>
         17        ADD_ARRAY_ELEMENT                                ~6      ~14
   13    18        CAST                                          8  ~15     <array>
         19        ADD_ARRAY_ELEMENT                                ~6      ~15
    3    20        ASSIGN                                                   !0, ~6
   16    21        ASSIGN                                                   !1, <array>
   17    22      > FE_RESET_R                                       $18     !0, ->42
         23    > > FE_FETCH_R                                               $18, !2, ->42
   18    24    >   FETCH_OBJ_R                                      ~19     !2, 'id'
         25        ISSET_ISEMPTY_DIM_OBJ                         0  ~20     !1, ~19
         26        BOOL_NOT                                         ~21     ~20
         27      > JMPZ                                                     ~21, ->32
   19    28    >   FETCH_OBJ_R                                      ~22     !2, 'id'
         29        ASSIGN_DIM                                               !1, ~22
         30        OP_DATA                                                  !2
         31      > JMP                                                      ->41
   21    32    > > FE_RESET_R                                       $24     !2, ->40
         33    > > FE_FETCH_R                                       ~25     $24, !3, ->40
         34    >   ASSIGN                                                   !4, ~25
   22    35        FETCH_OBJ_R                                      ~27     !2, 'id'
         36        FETCH_DIM_W                                      $28     !1, ~27
         37        ASSIGN_OBJ                                               $28, !4
         38        OP_DATA                                                  !3
   21    39      > JMP                                                      ->33
         40    >   FE_FREE                                                  $24
   17    41    > > JMP                                                      ->23
         42    >   FE_FREE                                                  $18
   26    43        INIT_FCALL                                               'ksort'
         44        SEND_REF                                                 !1
         45        DO_ICALL                                                 
   27    46        INIT_FCALL                                               'var_export'
         47        INIT_FCALL                                               'array_values'
         48        SEND_VAR                                                 !1
         49        DO_ICALL                                         $31     
         50        SEND_VAR                                                 $31
         51        DO_ICALL                                                 
         52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.91 ms | 1400 KiB | 19 Q