3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ (object) ['id' => 100, 'name' => 'Muhammad'], (object) ['id' => 102, 'name' => 'Ibrahim'], (object) ['id' => 101, 'name' => 'Sumayyah'] ]; $array2 = [ (object) ['id' => 100, 'name' => 'Muhammad'], (object) ['id' => 103, 'name' => 'Yusuf'] ]; $merged_keyed = array_column(array_merge($array1,$array2), NULL, 'id'); ksort($merged_keyed); print_r(array_values($merged_keyed));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpHpi
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array1, !1 = $array2, !2 = $merged_keyed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~3      <array>
          1        INIT_ARRAY                                       ~4      ~3
    4     2        CAST                                          8  ~5      <array>
          3        ADD_ARRAY_ELEMENT                                ~4      ~5
    5     4        CAST                                          8  ~6      <array>
          5        ADD_ARRAY_ELEMENT                                ~4      ~6
    2     6        ASSIGN                                                   !0, ~4
    9     7        CAST                                          8  ~8      <array>
          8        INIT_ARRAY                                       ~9      ~8
   10     9        CAST                                          8  ~10     <array>
         10        ADD_ARRAY_ELEMENT                                ~9      ~10
    8    11        ASSIGN                                                   !1, ~9
   13    12        INIT_FCALL                                               'array_column'
         13        INIT_FCALL                                               'array_merge'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                         $12     
         17        SEND_VAR                                                 $12
         18        SEND_VAL                                                 null
         19        SEND_VAL                                                 'id'
         20        DO_ICALL                                         $13     
         21        ASSIGN                                                   !2, $13
   14    22        INIT_FCALL                                               'ksort'
         23        SEND_REF                                                 !2
         24        DO_ICALL                                                 
   15    25        INIT_FCALL                                               'print_r'
         26        INIT_FCALL                                               'array_values'
         27        SEND_VAR                                                 !2
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.23 ms | 1457 KiB | 18 Q