3v4l.org

run code in 300+ PHP versions simultaneously
<?php $o1 = new stdClass(); $o1->id = 123; $o1->title = 'test'; $o2 = new stdClass(); $o2->id = 456; $o2->title = 'test2'; $arrofobjects = [ $o1,$o2 ]; var_dump($arrofobjects); $newArr = array_map(function($obj) { return [$obj->id => $obj->title]; }, $arrofobjects); var_dump($newArr);

preferences:
32.33 ms | 402 KiB | 5 Q