php读取一行 随机读一行file 函数 随机读文件夹的*.txt内容
# 读取文件随机一行
$lines = @file('peizhi/keyword/1.txt');
$keyword_nr = trim(lines[mt_rand(0, count($keyword_qbnr) - 1]);
#如果文件不存在或无法读取,file() 函数会返回 false 并可能产生警告
#(除非使用了 @ 运算符来抑制错误)。
# 读取文件夹下 随机一个txt文件
$txt_arr = array();
foreach (glob('files/*.txt') as $txt_now) {
$txt_arr [] = basename($txt_now);
}