今天上午醒来,看越狱,起了这个念头。
.srt是文本格式的字幕。正好有中文,也有英文的。
于是合并2个文件,中英文对照,呵呵,边看片,边学学英语嘛。
.srt是文本格式的字幕。正好有中文,也有英文的。
于是合并2个文件,中英文对照,呵呵,边看片,边学学英语嘛。
<?php
//require_once("iecho.php");
/**
* 合并.srt中英文字幕
* bailing
* 2007-01-27
*/
$enfile="prison.break.s02e12.hdtv.xvid-xor.en.srt";
$gbfile="prison.break.s02e12.hdtv.xvid-xor.gb.srt";
$en=file_get_contents ( $enfile );
$gb=file_get_contents ( $gbfile );
$enlines = explode("\r\n\r\n",$en);
$gblines = explode("\r\n\r\n",$gb);
$n=count($enlines);
for ($i=0;$i<$n ;$i++ )
{
$enline = &$enlines[$i];
$gbline = &$gblines[$i];
$ena = explode( "\r\n",$enline );
$gba = explode( "\r\n",$gbline );
$enTca = array_slice($ena , 2);
$enTc = join("\r\n",$enTca);
$gbTca = array_slice($gba , 2);
$gbTc = join("\r\n",$gbTca);
$tmpEnArr[$ena[1]] = array( $ena[0] , $ena[1] , $enTc );
$tmpGbArr[$gba[1]] = array( $gba[0] , $gba[1] , $gbTc );
}
foreach( $tmpEnArr as $key=>$ena)
{
$gba = $tmpGbArr[$key];
$engbTc= $ena[2]."\r\n".$gba[2];
$engbLine = $ena[0]."\r\n".$ena[1]."\r\n".$engbTc;
$engblines[] = $engbLine;
}
//pr($engblines);
$data = implode( "\r\n\r\n" , $engblines );
$rt = file_put_contents ( "engb.srt" , $data);
?>
//require_once("iecho.php");
/**
* 合并.srt中英文字幕
* bailing
* 2007-01-27
*/
$enfile="prison.break.s02e12.hdtv.xvid-xor.en.srt";
$gbfile="prison.break.s02e12.hdtv.xvid-xor.gb.srt";
$en=file_get_contents ( $enfile );
$gb=file_get_contents ( $gbfile );
$enlines = explode("\r\n\r\n",$en);
$gblines = explode("\r\n\r\n",$gb);
$n=count($enlines);
for ($i=0;$i<$n ;$i++ )
{
$enline = &$enlines[$i];
$gbline = &$gblines[$i];
$ena = explode( "\r\n",$enline );
$gba = explode( "\r\n",$gbline );
$enTca = array_slice($ena , 2);
$enTc = join("\r\n",$enTca);
$gbTca = array_slice($gba , 2);
$gbTc = join("\r\n",$gbTca);
$tmpEnArr[$ena[1]] = array( $ena[0] , $ena[1] , $enTc );
$tmpGbArr[$gba[1]] = array( $gba[0] , $gba[1] , $gbTc );
}
foreach( $tmpEnArr as $key=>$ena)
{
$gba = $tmpGbArr[$key];
$engbTc= $ena[2]."\r\n".$gba[2];
$engbLine = $ena[0]."\r\n".$ena[1]."\r\n".$engbTc;
$engblines[] = $engbLine;
}
//pr($engblines);
$data = implode( "\r\n\r\n" , $engblines );
$rt = file_put_contents ( "engb.srt" , $data);
?>