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

WBOY
Release: 2016-06-13 12:54:54
Original
800 people have browsed it

随机读取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;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template