PHP code example of podlove / webvtt-parser

1. Go to this page and download the library: Download podlove/webvtt-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/ */

    

podlove / webvtt-parser example snippets


use Podlove\Webvtt\Parser;
use Podlove\Webvtt\ParserException;

$parser = new Podlove\Webvtt\Parser();
$content = "WEBVTT\n\n00:00:00.000 --> 01:22:33.440\nHello world\n\n01:22:33.440 --> 01:22:34.440\n<v Eric>Hi again\n";
$result = $parser->parse($content);
// [
//   "cues" => [
//     [
//       "voice" => "",
//       "start" => 0,
//       "end" => 4953.44,
//       "text" => "Hello world",
//       "identifier" => "",
//     ],
//     [
//       "voice" => "Eric",
//       "start" => 4953.44,
//       "end" => 4954.44,
//       "text" => "Hi again",
//       "identifier" => "",
//     ],
//   ],
// ]