这看起来有点奇怪,但是否有任何脚本会生成随机评论,有点像聊天室评论。
随机的东西,比如“我很无聊”、“嘿,人们”、“要登录 cya”、“有人看过这部电影_ ”。
有人遇到过这样的事情吗?
您可以通过组合来自两个数组的随机选择来生成随机注释。
一个用于人称代词,一个用于动作/动词...
$pronoun = array(
"I'm",
"You're"
"He's",
"She's",
"They're"
);
$action = array(
"stacking",
"overflowing",
"confused",
"bewildered",
"wondering how many more of these I can make up",
"getting bored... So that's enough for now..."
);
在每个数组上运行array_rand()
一次将返回一个随机索引,连接相应的值将生成一个注释。您必须加强阵列并使其适合您的需求。
$comment = $pronoun[array_rand($pronoun)] . ' ' . $action[array_rand($action)];
创建评论生成器功能将进一步简化使用该系统的过程 -
function generateComment(){
global $pronoun,$action;
return $pronoun[array_rand($pronoun)] . ' ' . $action[array_rand($action)]
}
$comments = array("Im bored", "Hey people", "Gonna log cya", "Anyone seen the film");
$random_comment = array_rand($comments);
echo $comments[$random_comment];
$result = mysql_query("SELECT `comment` FROM `comments` ORDER BY RAND() LIMIT 0,1");
if($result) echo mysql_result($result, 0);
$comments = array("Im bored", "Hey people", "Gonna log cya", "Anyone seen the film");
shuffle($comments);
echo $comments[0];//1,2,3.....