我正在尝试构建一个 PHP 脚本来逐行读取远程文件并检查是否有某些单词然后将其导出。
<?php
$user=strip_tags($_GET['username']);
$pas=strip_tags($_GET['password']);
$data = file_get_contents('URL='.$user.'&password='.$pas.'&type=m3u_plus&output=mpegts', 'r');
$data = explode("\n", $data);
$long=count($data);
$file[0]="#EXTM3U";
$f=2;
$x=2;
while ($x <= $long){
$test=substr($data[$x], 27, 6);
if ($test == "series"){
$file[$f-1]=$data[$x-1];
$file[$f]=$data[$x];
$f=$f+2;
}
$x=$x+2;
}
$file = implode("\n", $file);
?>
我需要脚本在这里检查:
$file[$f-1]=$data[$x-1];
对于 Number : 2020 ,如果存在的话。如果存在输出,则继续下一行。