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));

preferences:
50.2 ms | 408 KiB | 5 Q