PHP在电影图像中的妙用 合并汉英字幕
<DIV12px">英文字幕:<BR><BR>1<BR>00:00:00,750 --> 00:00:02,350<BR>previously on prison break:<BR>2<BR>00:00:02,380 --> 00:00:05,000<BR>Give me the number for a sundown tel,please?<BR><BR>中文字幕:<BR>1<BR>00:00:00,750 --> 00:00:02,350<BR>越狱前情提要<BR>2<BR>00:00:02,380 --> 00:00:05,000<BR>请帮我查下Sundown旅馆的电话<BR><BR>合并后:<BR>1 <BR>00:00:00,750 --> 00:00:02,350 <BR>越狱前情提要 <BR>previously on prison break: <BR><BR>2 <BR>00:00:02,380 --> 00:00:05,000 <BR>请帮我查下Sundown旅馆的电话 <BR>Give me the number for a sundown tel,please? <BR><BR><A onclick="javascript:tagshow(event, 'PHP');" href="javascript:;" target=_self><U><STRONG><FONT size=3>PHP</FONT></STRONG></U></A>代码:<BR><BR><DIV ><DIV ><Ahref="http://www.phpchina.com/bbs/thread-11911-1-1.html###" onclick="copycode($('code0'));"><FONT size=3></FONT></A></DIV>CODE:</DIV><DIVid=code0><?<BR>//////////////////////////<BR>//下面是英文剧本部分采集//<BR>//////////////////////////<BR>$cc=0; //数组开始量<BR>$filename = "./en.txt";<BR>$handle = file($filename);<BR>$enew = array();<BR>$total = array();<BR>$cc_total = 0;<BR>$cc_e_total = 4;<BR>$en_start =0;<BR>foreach ($handle as $key => $value)<BR>{<BR> <BR> if(ereg("^",$value))<BR>{<BR> if ($value==($en_start+1))<BR> {<BR> $enew[$cc]=$key+2; //+2是为了把文字部分定位 因为数字和文字差两行。$gb_key+2为txt文本中文字所在的行数。<BR> $cc++;<BR> $en_start++;<BR> }<BR>}<BR>}<BR>reset($handle); //把英文剧本指针返回第一个。<BR>//下面是中文<BR>$gb_cc=0;<BR>$gb_start = 0;<BR>$gb_filename = "./gb.txt";<BR>$gb_handle = file($gb_filename);<BR>$gb_new = array();<BR>foreach ($gb_handle as $gb_key => $gb_value)//$gb_handle是$gb_handle=1 $gb_handle=00:33:47,890 --> 00:33:48,610 <BR>{<BR> <BR> if(ereg("^",$gb_value))<BR>{<BR> <BR> if ($gb_value==($gb_start+1))<BR> {<BR> $gb_new[$gb_cc]=$gb_key; //+2是为了把文字部分定位 因为数字和文字差两行。$gb_key+2为txt文本中文字所在的行数。<BR> $gb_cc++;<BR> $gb_start++;<BR> }<BR> <BR> <BR>}<BR>}<BR>reset($gb_handle); //把英文剧本指针返回第一个。<BR><BR>foreach ($gb_new as $new_key => $new_value)//中文在先$new_value开始于0<BR>{<BR> $total[$cc_total]=$gb_handle[$new_value];<BR> $total[$cc_total+1]=$gb_handle[$new_value+1];<BR> $total[$cc_total+2]=$gb_handle[$new_value+2];<BR> $total[$cc_total+3]=$gb_handle[$new_value+3];<BR> //上面四个为中文 INDEX 和时间 和两行内容<BR> $cc_total=$cc_total+7; //指针移动到$total<BR>}<BR>foreach ($enew as $e_new_key => $e_new_value)<BR>{<BR> $total[$cc_e_total]=$handle[$e_new_value];<BR> $total[$cc_e_total+1]=$handle[$e_new_value+1];<BR> $cc_e_total=$cc_e_total+7;<BR>}<BR>$total_count=count($total);<BR>for($e=0;$e<$total_count;$e++)<BR>{<BR> <BR> echo $total[$e]."<br />";<BR><BR><BR>}<BR><BR>?></DIV><BR></DIV><DIV12px">更多,请点击:<A href="http://www.phpchina.com/bbs/thread-11911-1-1.html"><FONT size=3>http://www.phpchina.com/bbs/thread-11911-1-1.html</FONT></A></DIV><DIV12px"> </DIV>
页:
[1]