3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ (object) ['ID' => 113, 'title' => 'text'], (object) ['ID' => 114, 'title' => 'text text text'], (object) ['ID' => 115, 'title' => 'text text'], (object) ['ID' => 116, 'title' => 'text'], ]; $result = []; foreach ($array as $obj) { $id = $obj->ID; unset($obj->ID); $result[$id] = $obj; } var_export($result); echo "\n---\n"; var_export($array);

preferences:
65.01 ms | 1194 KiB | 5 Q