I am trying to build a PHP script to read a remote file line by line and check if there is some certain word then export it.
<?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);
?>
I need the script to check here :
$file[$f-1]=$data[$x-1];
For the Number : 2020 , and if it exists. If it exists output otherwise go on to the next line.