3v4l.org

run code in 500+ PHP versions simultaneously
<?php $prop['created_date'] = '2022-04-07 13:38:15.000000'; $obj['files'] = [ ["20220407_10_22_30_L100.SVL", 2, "20220407", 4766, 307, 101366, "2022-04-07 13:24:10"], ["20220407_10_22_30_L101.SVL", 3, "20220407", 4767, 308, 101367, "2022-04-07 13:29:10"], ["20220407_10_22_30_L102.SVL", 4, "20220407", 4768, 309, 101368, "2022-04-07 13:34:10"], ["20220407_10_22_30_L103.SVL", 5, "20220407", 4769, 310, 101369, "2022-04-07 13:39:10"], ["20220407_10_22_30_L104.SVL", 6, "20220407", 4770, 311, 101370, "2022-04-07 13:44:10"], ["20220407_10_22_30_L105.SVL", 7, "20220407", 4771, 312, 101371, "2022-04-07 13:49:10"], ]; // prepare the date range data only once, before looping $from = date('Y-m-d H:i:s', strtotime($prop['created_date'] . ' - 10 minutes')); $to = date('Y-m-d H:i:s', strtotime($prop['created_date'] . ' + 10 minutes')); $result =[]; foreach ($obj['files'] as $file) { if ($from <= $file[6] && $file[6] <= $to) { $result[] = [$file[0], $file[6]]; } } var_export($result);

preferences:
103.46 ms | 1323 KiB | 5 Q