Don't use short opening tags. They've been deprecated and may be disabled on the user's server.
Header("Location: $img");
The Location header takes an absolute URI.
Code:
<?php
define('FROM_TIME', 0);
define('IMAGE_PATH', 1);
$times = array(
array(0, 'night.png'),
array(6, 'morning.png),
array(10, 'day.png'),
array(20, 'night.png'));
function getFloored($arr, $val) {
for ($i = 0; $i < count($arr); ++$i)
if ($arr[$i][0] > $val)
return $arr[$i - 1][1];
return false;
}
$t = getFloored($times, date('H') + 0);
$img = sprintf('<img src="%s" alt="%s">', $t = $t[IMAGE_PATH], basename($t, '.png'));
?>
Bookmarks