【发布时间】:2012-04-04 12:59:07
【问题描述】:
您好,我有这个基本的随机引用脚本,但我希望它以数组的形式输出页面,即代替“echo $quote”,使用“include('text.php, text2.php , text3.php');"等等
不太清楚该怎么做。有什么想法吗?
我还希望计时器成为突出的选择功能,以便它从循环的列表中进行选择,而不是随机拉出。
谢谢你:)
<?php
$cachefile = './current_t_id';
$time = $id = null;
$change_every = 3600;
include('text.php');
if(is_file($cachefile)) {
list($time, $id) = explode(' ', file_get_contents($cachefile));
}
if(!$time || time() - $time > $change_every) {
srand ((double) microtime() * 100000);
$id = rand(0,count($quotes)-1);
file_put_contents($cachefile, time().' '.$id); // update cache
}
echo ($quotes[$id]);
?>
【问题讨论】:
-
包含的文件中有什么???
-
你已经给出了一个解决方案..你说谢谢..你还想要什么???你应该做的是接受或更新你需要更多的问题
-
在您提供帮助后,我删除了此评论。对不起
标签: php random timer timer-jobs