2011-10-26 86 views

回答

3
$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. 
+0

'echo = $ result [array_rand($ result)];' ? –

1
echo explode(',',file_get_contents('file.txt'))[rand(0,99)]; 

即它的代碼量最少。

相關問題