Supposing naa kay array like this one:
Code:
$images = array('Mon' => array(0 => 'autodj.jpg',
9 => 'blue.jpg',
11 => 'kokj.jpg',
15 => 'jaycee.jpg',
20 => 'dory.jpg'),
'Tue' => array(0 => 'autodj.jpg',
9 => 'blue.jpg',
11 => 'kokj.jpg',
15 => 'jaycee.jpg',
20 => 'dory.jpg'),
'Wed' => array(0 => 'autodj.jpg',
9 => 'blue.jpg',
11 => 'kokj.jpg',
15 => 'jaycee.jpg',
20 => 'dory.jpg'));
Then to find the current image maghimo ka ug function nga something like this:
Code:
function current_dj()
{
global $images;
$day = date('D');
$time = date('G');
$img = '';
/* Check what day today is. */
if(isset($images[$day])) {
/* Check if we have a DJ for the specified hour. */
if(isset($images[$day][$time])) {
$img = $v;
} else {
foreach(array_reverse($images[$day], TRUE) as $k => $v) {
if($k < $time) {
$img = $v;
break;
}
}
}
}
return $img;
}
Then experiment lang sa katong array.