3v4l.org

run code in 300+ PHP versions simultaneously
<?php $db = [ ['dates' => 'Sep-2022', 'income' => 1864], ['dates' => 'Oct-2022', 'income' => 548] ]; $lookup = array_column($db, null, 'dates'); $year = date('Y'); for ($i = 1; $i < 13 ; ++$i) { $date = date('M-Y', strtotime("$year-$i-01")); $months[] = $lookup[$date] ?? ['dates' => $date, 'income' => 0]; } var_export($months);
Output for rfc.property-hooks, git.master, git.master_jit
array ( 0 => array ( 'dates' => 'Jan-2022', 'income' => 0, ), 1 => array ( 'dates' => 'Feb-2022', 'income' => 0, ), 2 => array ( 'dates' => 'Mar-2022', 'income' => 0, ), 3 => array ( 'dates' => 'Apr-2022', 'income' => 0, ), 4 => array ( 'dates' => 'May-2022', 'income' => 0, ), 5 => array ( 'dates' => 'Jun-2022', 'income' => 0, ), 6 => array ( 'dates' => 'Jul-2022', 'income' => 0, ), 7 => array ( 'dates' => 'Aug-2022', 'income' => 0, ), 8 => array ( 'dates' => 'Sep-2022', 'income' => 1864, ), 9 => array ( 'dates' => 'Oct-2022', 'income' => 548, ), 10 => array ( 'dates' => 'Nov-2022', 'income' => 0, ), 11 => array ( 'dates' => 'Dec-2022', 'income' => 0, ), )

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:
41.48 ms | 1396 KiB | 4 Q