Created
November 6, 2023 19:19
-
-
Save kiang/2ce686084368cfb2ed40beeaf0be40fb to your computer and use it in GitHub Desktop.
extract text from srt file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$c = file_get_contents(__DIR__ . '/captions.srt'); | |
$parts = explode("\n\n", $c); | |
foreach($parts AS $part) { | |
$lines = explode("\n", $part); | |
array_shift($lines); | |
array_shift($lines); | |
echo implode("\n", $lines) . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment