Auref Pourkarimi Auref Pourkarimi - 7 months ago 419
PHP Question

How i extract m3u8 of this url by regex?

I want to extract m3u8?id= of this link :

result of extract to be this :

and this is my code but it doesn't work:

$streamSite = "";

function writeFile($url, $channel) {
$File = $channel.".strm";
$Handle = fopen($File, 'w');
fwrite($Handle, $url);

$input = @file_get_contents($streamSite) or die("Could not access file: $url");

preg_match("/(id\=[^\&\">]+)/", $input, $matches);

echo $matches[1];



If I understood correctly your question, you want to capture the full link from the url content using regex.

You can use this regex then:


Working demo

Match information

1.  [665-1042]  ``