1
如何从逗号分隔的文字中挑选一个随机单词?从Php中的文本文件中选择一个单词?
如何从逗号分隔的文字中挑选一个随机单词?从Php中的文本文件中选择一个单词?
$var = file_get_contents('the_file.txt'); //Take the contents from the file to the variable
$result = explode(',',$var); //Split it by ','
echo = $result[array_rand($result)]; //Return a random entry from the array.
echo explode(',',file_get_contents('file.txt'))[rand(0,99)];
即它的代码量最少。
'echo = $ result [array_rand($ result)];' ? –