Heim >Backend-Entwicklung >PHP-Tutorial > 随机读取TXT内容的有关问题!

随机读取TXT内容的有关问题!

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:54:54866Durchsuche

随机读取TXT内容的问题!!
$file=file('webyuan.txt');
$file2=file('lk.txt');
$max=count($file)-1;
$max2=count($file2)-1;
for($i=0;$i   $index=mt_rand(0,$max);
  $index2=mt_rand(0,$max2);
$temp = trim($file["$index"]);
$temp2 = trim($file2["$index2"]);
echo $temp2;
}

这个可以随机输出5个关键词

for{}括号外
输出$temp2就只能得到一个关键词了,
请问如何才能在在括号外也可以随机输出5个关键词


------解决方案--------------------
for($i=0;$i   $index=mt_rand(0,$max);
  $index2=mt_rand(0,$max2);
$temp = trim($file["$index"]);
$temp2 .= trim($file2["$index2"]);
}
echo $temp2;
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn