随着每页刷新使用php随机生成文本。是否有更清洁的方法来解决这个问题?另外,这可以用jquery来完成吗?
<?php
$random_text = array("Random Text 1",
"Random Text 2",
"Random Text 3",
"Random Text 4",
"Random Text 5");
srand(time());
$sizeof = count($random_text);
$random = (rand()%$sizeof);
print("$random_text[$random]");
?>
答案 0 :(得分:8)
$random_text = array("Random Text 1",
"Random Text 2",
"Random Text 3",
"Random Text 4",
"Random Text 5");
print_r($random_text[array_rand($random_text)]);