<?php   
$txt = "http://www.xxx.cn/sitemap.txt"; //读取远程txt;
//是否存在
if(file_get_contents($txt)){
$data = file($txt); //将文件存放在一个数组中;
$num = count($data); //条数;
$id = mt_rand(0,$num-1); //随机数字;
$url = chop($data[$id]); //显示第几行数据,并去除空格;
echo "$url";  //随机显示一条域名
}
echo "</br>";
echo "zongtiaoshu:"."$num";
echo "</br>";
for ($i=0; $i < $num ; $i++) {
    echo $data[$i]."</br>";
}
//header("Location: $url");  //开始随机跳转
?>

php读取在线远程txt文档内容到数组并遍历

 

主要用于遍历网站在线sitemap.txt内容读取。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2021-12-04
  • 2022-12-23
  • 2022-02-09
  • 2021-09-05
猜你喜欢
  • 2021-05-28
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案