3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json='[{"from":"2019-07-22 09:00:00","to":"2019-07-22 11:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Close"},{"from":"2019-07-22 07:00:00","to":"2019-07-22 08:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Close"},{"from":"2019-07-22 07:00:00","to":"2019-07-22 08:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Open"},{"from":"2019-07-22 20:00:00","to":"2019-07-22 22:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Open"},{"from":"2019-07-22 11:00:00","to":"2019-07-22 17:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Open"},{"from":"2019-07-22 20:00:00","to":"2019-07-22 22:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Close"},{"from":"2019-07-22 07:00:00","to":"2019-07-22 15:00:00","rendering":"background","resource":"3529","backgroundColor":"#660000","purpose":"Close"}]'; //var_export(json_decode($json, true)); foreach (json_decode($json, true) as $i => $entry) { if (!$i) { $result[] = $entry; } else { foreach ($result as $stored) { if (($entry['from'] >= $stored['from'] && $entry['from'] < $stored['to']) || ($entry['to'] > $stored['from'] && $entry['to'] <= $stored['to'])) { continue 2; } } $result[] = $entry; } } var_export($result);
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array ( 0 => array ( 'from' => '2019-07-22 09:00:00', 'to' => '2019-07-22 11:00:00', 'rendering' => 'background', 'resource' => '3529', 'backgroundColor' => '#660000', 'purpose' => 'Close', ), 1 => array ( 'from' => '2019-07-22 07:00:00', 'to' => '2019-07-22 08:00:00', 'rendering' => 'background', 'resource' => '3529', 'backgroundColor' => '#660000', 'purpose' => 'Close', ), 2 => array ( 'from' => '2019-07-22 20:00:00', 'to' => '2019-07-22 22:00:00', 'rendering' => 'background', 'resource' => '3529', 'backgroundColor' => '#660000', 'purpose' => 'Open', ), 3 => array ( 'from' => '2019-07-22 11:00:00', 'to' => '2019-07-22 17:00:00', 'rendering' => 'background', 'resource' => '3529', 'backgroundColor' => '#660000', 'purpose' => 'Open', ), )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
177.03 ms | 408 KiB | 5 Q