Show image/url on a specific date - Php
Image displaying
Snippet Code
This function is used to show an image or an url to display on a specific dates which are defined by a user
<?php
function imagedate(){
$date = "date.txt";
$fileread = fopen($date, "r");
$dateToshow = fread($fileread, filesize($date));
fclose($fileread);
$array = explode("y",$dateToshow);
foreach($array as $item){
$arr = explode(" ",$item);
if(date("Y-m-d") == $arr[0]){
$val = $arr[1];
$result = TRUE;
break;
}else{
$result = FALSE;
}
}
if($result){
return $val;
}else{
$def = explode(" ",$array[0]);
return $def[2];
}
}
$url = imagedate();
echo '<a href="'.$url.'">'.$url.'</a>';
?>
/*******************Text Document************************************/
default
2010-12-17 /images/index.gif
2011-01-01 /images/index1.gif
2011-01-14 /images/index2.gif
Tags