3v4l.org

run code in 300+ PHP versions simultaneously
<?php $oldArr = [ ['sno' => 'q3', 'result' => '15'], ['sno' => 'q1', 'result' => '5'], ['sno' => 'q2', 'result' => '10'] ]; $newArr = array_reduce($oldArr, function($carry, $item){ $carry[$item["sno"]] = $item["result"]; return $carry; }); var_dump($newArr);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["q3"]=> string(2) "15" ["q1"]=> string(1) "5" ["q2"]=> string(2) "10" }

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:
129.65 ms | 405 KiB | 5 Q