random image
Posted: Sun Feb 22, 2004 12:04 pm
Hi,
I'm using the following code to display a random image and link from a file named imageandlinks.php
<?
$array = file("imageandlinks.php");
shuffle($array);
for ($i=0; $i<1; $i++) {
echo $array[$i];
}
?>
This code displays one image and link from the imageandlinks.php file randomly.( each time the page is loaded / or refreshed)
I would like to modify this code for it to display a random image and link from the imageandlinks.php file for 1 day ( or 24 hours) and set a cookie for 30 days for each image that have been displayed.
So if a visitor comes back the same day he/she will see the same picture (also if you click refresh). the visitor should see a new image daily but the cookie should avoid the visitor to see the same image twice within the 30 days.
I appreciate your help.
I'm using the following code to display a random image and link from a file named imageandlinks.php
<?
$array = file("imageandlinks.php");
shuffle($array);
for ($i=0; $i<1; $i++) {
echo $array[$i];
}
?>
This code displays one image and link from the imageandlinks.php file randomly.( each time the page is loaded / or refreshed)
I would like to modify this code for it to display a random image and link from the imageandlinks.php file for 1 day ( or 24 hours) and set a cookie for 30 days for each image that have been displayed.
So if a visitor comes back the same day he/she will see the same picture (also if you click refresh). the visitor should see a new image daily but the cookie should avoid the visitor to see the same image twice within the 30 days.
I appreciate your help.