3v4l.org

run code in 300+ PHP versions simultaneously
<?php $jobs = [ ['count' => 3, 'yearmonth' => '2019-7'], ['count' => 3, 'yearmonth' => '2019-9'], ['count' => 5, 'yearmonth' => '2019-10'], ]; $dates = [ ['yearmonth' => '2019-6'], ['yearmonth' => '2019-7'], ['yearmonth' => '2019-8'], ['yearmonth' => '2019-9'], ['yearmonth' => '2019-10'], ]; $lookup = array_column($jobs, null, 'yearmonth'); $result = []; foreach ($dates as $date) { $result[] = $lookup[$date['yearmonth']] ?? ['count' => 0] + $date; } var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'count' => 0, 'yearmonth' => '2019-6', ), 1 => array ( 'count' => 3, 'yearmonth' => '2019-7', ), 2 => array ( 'count' => 0, 'yearmonth' => '2019-8', ), 3 => array ( 'count' => 3, 'yearmonth' => '2019-9', ), 4 => array ( 'count' => 5, 'yearmonth' => '2019-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:
30.32 ms | 406 KiB | 5 Q