3v4l.org

run code in 300+ PHP versions simultaneously
<?php $m3u = '#EXTM3U #EXTINF:-1 tvg-name="Canal 26" tvg-logo="https://demo.com/xDjOUuz.png" group-title="Argentina", https://demolivevideo1.com/playlist.m3u8 #EXTINF:-1 tvg-name="LN" tvg-logo="https://demo2.com/vJYzGt1.png" group-title="Argentina", https://demolivevideo2.com/playlist.m3u8 #EXTINF:-1 tvg-name="ABC" tvg-logo="https://demo3.com/5CVl5EF.png" group-title="Australia", https://demolivevideo3.com/playlist.m3u8""" '; $newFile = '<?xml version="1.0" encoding="utf-8"?> <data></data> '; $doc = new DOMDocument(); $doc->loadXML($newFile); $xpath = new DOMXpath($doc); $destination = $xpath->query('/data'); $step1 = explode('#EXTINF:-1 ',str_replace('#EXTM3U','',$m3u)); $step2 = array_slice($step1,1); foreach ($step2 as $item) { $step3 = str_replace('" ','" xxx',explode(',', $item))[0]; $step4 = explode('xxx',$step3); $link = explode(',',$item)[1]; $params = []; foreach ($step4 as $step) { $param = explode('=',$step)[1]; array_push($params,$param); } $chan = " <channels> <name>{$params[0]}</name> <banner>{$params[1]}</banner> <url>{$link}</url> <country>{$params[2]}</country> </channels>"; $template = $doc->createDocumentFragment(); $template->appendXML($chan); $destination[0]->appendChild($template); }; echo $doc->saveXml();
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
<?xml version="1.0" encoding="utf-8"?> <data> <channels> <name>"Canal 26" </name> <banner>"https://demo.com/xDjOUuz.png" </banner> <url> https://demolivevideo1.com/playlist.m3u8 </url> <country>"Argentina"</country> </channels> <channels> <name>"LN" </name> <banner>"https://demo2.com/vJYzGt1.png" </banner> <url> https://demolivevideo2.com/playlist.m3u8 </url> <country>"Argentina"</country> </channels> <channels> <name>"ABC" </name> <banner>"https://demo3.com/5CVl5EF.png" </banner> <url> https://demolivevideo3.com/playlist.m3u8""" </url> <country>"Australia"</country> </channels></data>
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
133.62 ms | 408 KiB | 5 Q