PHP code example of akaramires / m3u-parser

1. Go to this page and download the library: Download akaramires/m3u-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

akaramires / m3u-parser example snippets


use Akaramires\M3uParser\Processors\PlaylistProcessor;
use Akaramires\M3uParser\Sources\FileSource;

...

$source = new FileSource(__DIR__ . '/../Data/playlist.m3u');

/** @var PlaylistProcessor $processor */
$processor = app(PlaylistProcessor::class);

$processor->load($source);
$processor->parse();

$playlist = $processor->getPlaylist();

[
  "inlineAttributes" => [
    [
      "key" => "cache",
      "value" => "500",
    ],
    [
      "key" => "playlist",
      "value" => "1",
    ],
  ],
  "attributes" => [],
  "attributesWithoutValue" => [],
  "channels" => [
    [
      "title" => "TVMatic Comedy",
      "duration" => "0",
      "url" => "https://iptv.com/channel.m3u8",
      "inlineAttributes" => [
        [
          "key" => "tvg-country",
          "value" => "es",
        ],
        [
          "key" => "group-title",
          "value" => "Spain",
        ],
      ],
      "attributes" => [],
    ]
    [
      "title" => "TVMatic Comedy 2",
      "duration" => "0",
      "url" => "https://iptv.com/channel.m3u8",
      "inlineAttributes" => [],
      "attributes" => [],
    ],
  ],