3v4l.org

run code in 300+ PHP versions simultaneously
<?php $d = [ ['type' => 25500, 'month' => 'July'], ['type' => 5465, 'month' => 'January'], ['type' => 40000, 'month' => 'April'], ['type' => 35000, 'month' => 'June'], ['type' => 10000, 'month' => 'February'] ]; $allmonths = ['January', 'February', 'March', 'April', 'May','June','July','August', 'September','October','November','December']; $lookup = array_column($d, null, 'month'); // assign temporary keys for improved efficiency $result = []; foreach ($allmonths as $month) { $result[] = $lookup[$month] ?? ['type' => 0, 'month' => $month]; } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'type' => 5465, 'month' => 'January', ), 1 => array ( 'type' => 10000, 'month' => 'February', ), 2 => array ( 'type' => 0, 'month' => 'March', ), 3 => array ( 'type' => 40000, 'month' => 'April', ), 4 => array ( 'type' => 0, 'month' => 'May', ), 5 => array ( 'type' => 35000, 'month' => 'June', ), 6 => array ( 'type' => 25500, 'month' => 'July', ), 7 => array ( 'type' => 0, 'month' => 'August', ), 8 => array ( 'type' => 0, 'month' => 'September', ), 9 => array ( 'type' => 0, 'month' => 'October', ), 10 => array ( 'type' => 0, 'month' => 'November', ), 11 => array ( 'type' => 0, 'month' => 'December', ), )

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:
191.63 ms | 407 KiB | 5 Q