0
I have a file ". m3u" I need to return some data in list.
PHP example:
<?php
$m3u_file = file_get_contents('meuarquivo.m3u');
preg_match_all('/(tvg-name="(?<name>.*?)".+\n(?P<link>https?:\/\/.+))/',
$m3u_file, $channels, PREG_SET_ORDER);
?>
<ul>
<?php foreach($channels as $m3u_file): ?>
<li id="title"><?php echo $m3u_file["name"] ?></li>
<li id="URL"><?php echo str_replace(".ts", ".m3u8", $m3u_file["link"]) ?></li>
<?php endforeach; ?>
</ul>
Upshot:
<ul>
<li id="title">A&E</li>
<li id="URL">http://meucanal.tv:25461/9906</li>
<li id="title">AMC</li>
<li id="URL">http://meucanal.tv:25461/9904</li>
<li id="title">AMC HD</li>
<li id="URL">http://meucanal.tv:25461/9902</li>
<li id="title">Animal Planet</li>
<li id="URL">http://meucanal.tv:25461/9900</li>
<li id="title">Arte 1</li>
<li id="URL">http://meucanal.tv:25461/9893</li>
<li id="title">AXN</li>
<li id="URL">http://meucanal.tv:25461/9897</li>
</ul>
Using the PHP preg_match_all with this result, but I need to do the same thing using javascript.
tried using the match()
but I couldn’t get the same result.
I’m sorry for the mistakes, I’m new here kkk
I could not understand a pattern of what you want to take with the given example. I suggest editing the question and better detail what you want and what you have already done.
– Sam