2 mrgao0916 Mrgao0916 于 2016.09.18 19:01 提问

怎么设置PHP图片循环播放,从1到10
$img = imagecreatetruecolor(20, 20);
date_default_timezone_set("PRC");
$arr = array(
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9");

//开始时间戳
//$starttime = strtotime("2016-7-21 20:38:00");
$starttime = strtotime("2014-12-13 20:38:00");
//结束时间戳
$endtime = time();
$link = "";
//计算天数
$timediff = $endtime - $starttime;
$days = intval($timediff / 86400);
$link .= $days."天";
//计算小时数
$remain = $timediff % 86400;
$hours = intval($remain / 3600);
if($hours < 10){
    $link .= "0".$hours."小时";
}else{
    $link .= $hours."小时";
}
//计算分钟数
$remain = $remain % 3600;
$mins = intval($remain / 60);
if($hours < 10){
    $link .= "0".$mins."分钟";
}else{
    $link .= $mins."分钟";
}
//计算秒数
$secs = $remain % 60;
$hours."小时".$mins."分钟";
if($secs < 10){
    $link .= "0".$secs."秒</center></h1>";
}else{
    $link .= $secs."秒";
}

$color = imagecolorallocate($img, mt_rand(200,255), mt_rand(200,255), mt_rand(200,255));
$zcolor = imagecolorallocate($img, mt_rand(0,100), mt_rand(0,100),mt_rand(0,100));
echo "<center>";
echo "<h1>";
echo "<font color = ".$color.">".$link."</font>";
$text = mt_rand(0,8);
echo "<br/><font color = ".$zcolor.">".$arr["$text"]."</font>";
echo "</h1><br/>";

//随机读取图片
$i = mt_rand(1,10);
$img = "./Foreverimg/$i.jpg";
//显示图片
echo "<img src = ".$img." width='489.6' heigth='652.8'>";

echo "</center>";

//JS 页面自动刷新
echo ("<script type=\"text/javascript\">");
echo ("function fresh_page()");    
echo ("{");
echo ("window.location.reload();");
echo ("}"); 
echo ("setTimeout('fresh_page()',1000);");      
echo ("</script>");

现在只能做出来图片随机显示,想实现页面刷新一次更换下一站图片的效果

1个回答

devmiao
devmiao   Ds   Rxr 2016.09.19 00:22
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!