fork download
  1. <?php
  2. function closest($array, $number) {
  3. sort($array);
  4. foreach ($array as $a) {
  5. if ((int) $a > $number) return $a;
  6. }
  7. return end($array);
  8. }
  9.  
  10. $array = array('0730','0750','0810','0830','0840','0850','0900','0910','0920','0930','0940','0950',1000,1010,1020,1030,1040,1050,1100,1110,1120,1130,1140,1150,1210,1230,1250,1310,1330,1350,1410,1430,1450,1510,1530,1550,1610,1630,1650,1710,1720,1730,1740,1750,1800,1810,1820,1830,1840,1850,1900,1910,1920,1930,1940,1950,2000,2010,2020,2030,2040,2050,2100,2120,2140,2200,2220,2240,2300,2320);
  11.  
  12. $nexttime = closest($array, '0930');
  13. echo $nexttime;
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
0940