<?php
//Array com os horarios que possam ser imprimidos
$hora = array('13:55:40','13:56:40','13:58:41','13:59:40','14:01:00','14:02:00','14:04:40', '14:05:00','14:07:10','14:08:00','14:10:23', '14:11:23','14:13:39','14:14:23','14:16:39',
'14:17:23','14:19:13','14:20:23','14:22:40', '14:21:23','14:25:07', '14:26:23', '14:55:40');
//Intervalo que o usuario escolherá entre 3, 15, 30 ou 60
$interval = 15;
$val1 = $hora[0];
print $val1;
for ($i=0;$i<(count($hora)-1);$i++) {
$val2 = $hora[$i+1];
$datetime1 = new DateTime($val1);
$datetime2 = new DateTime($val2);
$intervalo = $datetime1->diff($datetime2);
$result = $intervalo->format('%i');
if($result == ($interval-1) || $result == ($interval)){
print ", ".$val2;
$val1 = $val2;
}
}
PD9waHAKCgkvL0FycmF5IGNvbSBvcyBob3JhcmlvcyBxdWUgcG9zc2FtIHNlciBpbXByaW1pZG9zCgkkaG9yYSA9IGFycmF5KCcxMzo1NTo0MCcsJzEzOjU2OjQwJywnMTM6NTg6NDEnLCcxMzo1OTo0MCcsJzE0OjAxOjAwJywnMTQ6MDI6MDAnLCcxNDowNDo0MCcsCgknMTQ6MDU6MDAnLCcxNDowNzoxMCcsJzE0OjA4OjAwJywnMTQ6MTA6MjMnLCAnMTQ6MTE6MjMnLCcxNDoxMzozOScsJzE0OjE0OjIzJywnMTQ6MTY6MzknLAoJJzE0OjE3OjIzJywnMTQ6MTk6MTMnLCcxNDoyMDoyMycsJzE0OjIyOjQwJywgJzE0OjIxOjIzJywnMTQ6MjU6MDcnLCAnMTQ6MjY6MjMnLCAnMTQ6NTU6NDAnKTsKCQoJLy9JbnRlcnZhbG8gcXVlIG8gdXN1YXJpbyBlc2NvbGhlcsOhIGVudHJlIDMsIDE1LCAzMCBvdSA2MAoJJGludGVydmFsID0gMTU7CgkKCSR2YWwxID0gJGhvcmFbMF07CgkKCXByaW50ICR2YWwxOwoJCglmb3IgKCRpPTA7JGk8KGNvdW50KCRob3JhKS0xKTskaSsrKSB7CgkK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