3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( 0 => (object) (array( 'id' => 1111, 'houseid' => 58, 'price' => 2995, )), 1 => (object) (array( 'id' => 1112, 'houseid' => 58, 'price' => 4050, )), 2 => (object) (array( 'id' => 1114, 'houseid' => 60, 'price' => 1695, )), 3 => (object) (array( 'id' => 1115, 'houseid' => 60, 'price' => 2250, )), 4 => (object) (array( 'id' => 1116, 'houseid' => 60, 'price' => 2295, )), ); $data = array_reduce($data, function ($a, $b) { $id = $b->houseid; unset($b->houseid); $a[$id][] = $b; return $a; }); var_dump($data); ?>
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [58]=> array(2) { [0]=> object(stdClass)#1 (2) { ["id"]=> int(1111) ["price"]=> int(2995) } [1]=> object(stdClass)#2 (2) { ["id"]=> int(1112) ["price"]=> int(4050) } } [60]=> array(3) { [0]=> object(stdClass)#3 (2) { ["id"]=> int(1114) ["price"]=> int(1695) } [1]=> object(stdClass)#4 (2) { ["id"]=> int(1115) ["price"]=> int(2250) } [2]=> object(stdClass)#5 (2) { ["id"]=> int(1116) ["price"]=> int(2295) } } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.21 ms | 402 KiB | 8 Q