Skip to content
ju edited this page Sep 23, 2013 · 8 revisions

Example:

<?php
require('src/SrtParser/srtFile.php');

try{
	$file = new \SrtParser\srtFile('./example.srt');
	  
	// get the text of the first entry
	echo  $file->getSub(0)->getText();
}
catch(Exeption $e){
	echo "Error: ".$e->getMessage()."\n";
}

Convert SubRip file (.srt) into WebVTT file (.vtt)

<?php
require('src/SrtParser/srtFile.php');

try{
	$srt = new \SrtParser\srtFile('my_subs.srt');
	$srt->setWebVTT(true);
	$srt->build(true);
	$srt->save('my_subs.vtt', true);
}
catch(Exeption $e){
	echo "Error: ".$e->getMessage()."\n";
}
Clone this wiki locally