fork(2) download
  1. <?php
  2.  
  3. //Array com os horarios que possam ser imprimidos
  4. $hora = array('13:55:40','13:56:40','13:58:41','13:59:40','14:01:00','14:02:00','14:04:40',
  5. '14:05:00','14:07:10','14:08:00','14:10:23','14:11:23','14:13:39','14:14:23','14:16:39',
  6. '14:17:23','14:19:13','14:20:23','14:22:40', '14:21:23','14:25:07', '14:26:23', '14:55:40');
  7.  
  8. //Intervalo que o usuario escolherį entre 3, 15, 30 ou 60
  9. $interval = 3;
  10.  
  11. $val1 = $hora[0];
  12.  
  13. print $val1;
  14. //
  15. $val1P = date( 'g:i a', strtotime($val1) );
  16.  
  17. for ($i=0;$i<(count($hora)-1);$i++) {
  18.  
  19. $val2 = $hora[$i+1];
  20. $val2P = date( 'g:i a', strtotime($val2) );
  21.  
  22. $datetime1 = new DateTime($val1P);
  23. $datetime2 = new DateTime($val2P);
  24.  
  25. $intervalo = $datetime1->diff($datetime2);
  26.  
  27. $result = $intervalo->format('%i');
  28.  
  29. if($result == $interval){
  30.  
  31. print ", ".$val2;
  32. $val1P = $val2P;
  33.  
  34. }
  35.  
  36. }
Success #stdin #stdout 0.01s 83904KB
stdin
Standard input is empty
stdout
13:55:40, 13:58:41, 14:01:00, 14:04:40, 14:07:10, 14:10:23, 14:13:39, 14:16:39, 14:19:13, 14:22:40, 14:25:07