Image can change on web page, you know...like showing different christmas pictures when web page loads on a users computer. I want them to see a different picture each time in php page.
$file=array();
$file[0]="file1.gif";
$file[1]="file2.gif";
$file[2]="file3.gif";
$file[3]="file4.gif";
$file[4]="file5.gif";
$file[5]="file6.gif";
$file[6]="file7.gif";
$file[7]="file8.gif";
$fileno=rand(0,7);
$filename=$file[$fileno];
echo '<img src="$filename" >';
?>
Why not remove the first part of your code and do something like this:
ReplyDelete<img src="file<?=rand(1,8)?>.gif" />
or
echo '<img src="file'.rand(1,8).'.gif" />';
Saves you 11 lines of code and you dont instantiate three unnecessary variables.