3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * step 1: create benchmark array * containing all consecutive dates from $start */ $start = '2019-10-27 16:30:00'; $days = 14; // total number of days (including $start) $dateObj = new DateTimeImmutable($start); $benchmarkDates[] = $dateObj->format('Y-m-d H:i:s'); // store the first bench date for ($i = 1; $i < $days; $i++) { $period = 'P' . $i . 'D'; $interval = new DateInterval($period); $dateObj0 = $dateObj->add($interval); $benchmarkDates[] = $dateObj0->format('Y-m-d H:i:s'); // store the next bench date } /* * create dummy array mimicking the OP's presented structure * create date gaps */ $start = '2019-10-27 16:30:00'; $days = 14; // total number of days (including $start) $dateObj = new DateTimeImmutable($start); $subject[0][] = ['datum' => $dateObj]; // store the first object for ($i = 2; $i < $days; $i += 2) { $period = 'P' . $i . 'D'; $interval = new DateInterval($period); $dateObj0 = $dateObj->add($interval); $subject[$i / 2][] = ['datum' => $dateObj0]; // store subsequent objects } /* step 2: get dates from subject array ($subject). */ foreach ($subject as $key => $value) { foreach ($value as $key => $value) { $subjectDates[] = $value['datum']->format('Y-m-d H:i:s'); // store dates } } /* * step 3: find / store missing dates * check subject against benchmark */ foreach($benchmarkDates as $key => $value) { if(!in_array($value, $subjectDates)) { $missingDates[] = $value; } } echo 'benchmark array:' . "\r\n"; print_r($benchmarkDates); echo 'subject array:' . "\r\n";; print_r($subjectDates); echo 'missing dates:' . "\r\n";; print_r($missingDates);
Output for git.master, git.master_jit, rfc.property-hooks
benchmark array: Array ( [0] => 2019-10-27 16:30:00 [1] => 2019-10-28 16:30:00 [2] => 2019-10-29 16:30:00 [3] => 2019-10-30 16:30:00 [4] => 2019-10-31 16:30:00 [5] => 2019-11-01 16:30:00 [6] => 2019-11-02 16:30:00 [7] => 2019-11-03 16:30:00 [8] => 2019-11-04 16:30:00 [9] => 2019-11-05 16:30:00 [10] => 2019-11-06 16:30:00 [11] => 2019-11-07 16:30:00 [12] => 2019-11-08 16:30:00 [13] => 2019-11-09 16:30:00 ) subject array: Array ( [0] => 2019-10-27 16:30:00 [1] => 2019-10-29 16:30:00 [2] => 2019-10-31 16:30:00 [3] => 2019-11-02 16:30:00 [4] => 2019-11-04 16:30:00 [5] => 2019-11-06 16:30:00 [6] => 2019-11-08 16:30:00 ) missing dates: Array ( [0] => 2019-10-28 16:30:00 [1] => 2019-10-30 16:30:00 [2] => 2019-11-01 16:30:00 [3] => 2019-11-03 16:30:00 [4] => 2019-11-05 16:30:00 [5] => 2019-11-07 16:30:00 [6] => 2019-11-09 16:30:00 )

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:
31.41 ms | 408 KiB | 5 Q