0

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.

Dave
  • 5,108
  • 16
  • 30
  • 40
ashari
  • 1
  • 1

1 Answers1

0

you can use this code structure:

//...  
//your code
$test=substr($data[$x], 27, 6);
if ($test == "series"){

    if (false === strstr($test, '2020')) {
        continue;
    } 

    echo $test;   

    $file[$f-1]=$data[$x-1];
    $file[$f]=$data[$x];
    $f=$f+2;
}
// your code
//...
Mike Foxtech
  • 1,633
  • 1
  • 6
  • 7