fork(1) download
  1. <?php
  2.  
  3. $current_time = '4:00';
  4. $time_slot = ['1:00','3:00','15:00','19:00'];
  5.  
  6. $current_date = new \DateTime($current_time);
  7.  
  8. foreach($time_slot as &$value) {
  9. if ($current_date > new \DateTime($value)) $value = null;
  10. }
  11. $time_slot = array_filter($time_slot);
  12.  
  13. var_dump($time_slot);
Success #stdin #stdout 0.04s 25984KB
stdin
Standard input is empty
stdout
array(2) {
  [2]=>
  string(5) "15:00"
  [3]=>
  &string(5) "19:00"
}