我有一个文本文件如下
href='https://www.example.com/tv/xxxxxxxx/playlist.m3u8'>TV 1
href='https://www.example.com/tv/xxxxxxxx/playlist.m3u8'>TV 2
href='https://www.example.com/tv/xxxxxxxx/playlist.m3u8'>TV 3
href='https://www.example.com/tv/xxxxxxxx/playlist.m3u8'>TV 4
href='https://www.example.com/tv/xxxxxxxx/playlist.m3u8'>TV 5
href='https://www.example.com/playlist/xxxxxxxx/playvod/vybz9h.mp4'>Film 1
href='https://www.example.com/playlist/xxxxxxxx/playvod/tq5mzt.mp4'>Film 2
href='https://www.example.com/playlist/xxxxxxxx/playvod/xegtnw.mp4'>Film 3
href='https://www.example.com/playlist/xxxxxxxx/playvod/16c9os.mp4'>Film 4
href='https://www.example.com/playlist/xxxxxxxx/playvod/r25dwc.mp4'>Film 5
作为一个非常长的文本文件,我想消除M3U8连接的唯一行,并仅保留那些带有电影链接的行。 可以这样做吗?
答案 0 :(得分:0)
$lines = file("filename");
$result = "";
foreach($lines as $line){
if(strpos($line, "M3U8")){
$line = "";
}
$result .= $line;
}
file_put_contents("filename", $result);
希望这会有所帮助。 :)