function preg_match_all

Asked

Viewed 70 times

0

I have that function:

preg_match_all('/(tvg-logo="(?<logo>.*?)".+group-title="(?<name>.*?)".+\n(?P<link>http?:\/\/.+))/', $response, $channels, PREG_SET_ORDER);

She scans a m3u8 list:

EXTINF:-1  tvg-logo="https://image.tmdb.org/t/p/w600_and_h900_bestv2/rHPGCpqsbg3WK90uig0KbxBtFrh.jpg" group-title="Vod! Ondemand!",Jumanji: Bem-Vindo à Selva (2017) - Dublado - 720p
http://cdn1.ntcdn.us/content/httpdelivery/filmes2018/JUMANJI2018DUB-ALTO.mp4

And display the information with this code:

foreach($channels as $channel): ?>
<li class="list-group-item">
    <a href="<?php echo $channel["link"] ?>" title="<?php echo $channel["name"] ?>">
        <img src="<?php echo $channel["logo"] ?>" class="img-responsive img-circle" />
        <div id="info_bar">
          <?php echo $channel["name"] ?>
        </div>
    </a>
</li>
<?php endforeach; ?>

I just need to get the name information, which is after the group title comma.

  • @Valdeirpsr can help me?

  • If possible, try as follows: https://regex101.com/r/NZVf7X/1

  • Is it possible to pick up different parts? for example: separate Movie name, year, dubbed or subtitled...

  • Yes, it is possible. But it is necessary that all are in the same pattern. Tìtulo (ano) - (Tipo do Audio) - (Qualidade). Otherwise the expression will be huge and may not work as expected.

  • Yes, they all follow the same pattern: group-title="Vod! Ondemand!" ,The Cult of Chucky (Voiced) - 2017 - 1080p. Only what changes sometimes is what’s inside group-title.

  • I was able to separate the group-title from the rest, but I was unable to separate only the... https://regex101.com/r/NZVf7X/2

  • Try it this way: https://regex101.com/r/NZVf7X/4

  • Oops, it worked! Thank you!

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.