Auref Pourkarimi Auref Pourkarimi - 1 year ago 726
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];


Answer Source

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]  ``
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download