PHP code example of vladwork555 / srt-parser

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

    

vladwork555 / srt-parser example snippets

`
$parser = new Parser();

$parser->loadString($formatted_caption_input);

$captions = $parser->parse();
`
foreach($captions as $caption){
    echo "Start Time: " . $caption->startTime;
    echo "End Time: " . $caption->endTime;
    echo "Text: " . $caption->text;
}
`
foreach($captions as $caption){
    $caption = $caption->toArray();
    echo "Start Time: " . $caption['start_time'];
    echo "End Time: " . $caption['end_time'];
    echo "Text: " . $caption['text'];
}
`
$url = "https://youtu.be/dQw4w9WgXcQ";
$video = new Video($url);
foreach ($captions as $caption) {
    $data = new VideoMetadata($caption->toArray());
    $video->videoMetadata()->save($data);
}