3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['level_id' => 1, 'level' => 'Trivial', 'description' => 'Foobar'], ['level_id' => 2, 'level' => 'Moderate', 'description' => 'Foobar'], ['level_id' => 3, 'level' => 'Challenging', 'description' => 'Foobar'], ['level_id' => 4, 'level' => 'Formidable'], ]; function toLookup(array $array): array { foreach ($array as $row) { $result[array_shift($row)] = count($row) === 1 ? current($row) : $row; } return $result ?? []; } var_export(toLookup($array));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 1 => array ( 'level' => 'Trivial', 'description' => 'Foobar', ), 2 => array ( 'level' => 'Moderate', 'description' => 'Foobar', ), 3 => array ( 'level' => 'Challenging', 'description' => 'Foobar', ), 4 => 'Formidable', )

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:
27.7 ms | 406 KiB | 5 Q