查看: 5951|回复: 0
打印 上一主题 下一主题

PHP在电影图像中的妙用 合并汉英字幕

[复制链接]
跳转到指定楼层
1#
发表于 2007-10-4 15:32:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
英文字幕:

1
00:00:00,750 --> 00:00:02,350
previously on prison break:
2
00:00:02,380 --> 00:00:05,000
Give me the number for a sundown tel,please?

中文字幕:
1
00:00:00,750 --> 00:00:02,350
越狱前情提要
2
00:00:02,380 --> 00:00:05,000
请帮我查下Sundown旅馆的电话

合并后:
1
00:00:00,750 --> 00:00:02,350
越狱前情提要
previously on prison break:

2
00:00:02,380 --> 00:00:05,000
请帮我查下Sundown旅馆的电话
Give me the number for a sundown tel,please?

PHP代码:


[Copy to clipboard]
CODE:
<?
//////////////////////////
//下面是英文剧本部分采集//
//////////////////////////
$cc=0; //数组开始量
$filename = "./en.txt";
$handle = file($filename);
$enew = array();
$total = array();
$cc_total = 0;
$cc_e_total = 4;
$en_start =0;
foreach ($handle as $key => $value)
{
   
   if(ereg("^[1-9]",$value))
{  
   if ($value==($en_start+1))
    {
     $enew[$cc]=$key+2; //+2是为了把文字部分定位 因为数字和文字差两行。$gb_key+2为txt文本中文字所在的行数。
     $cc++;
     $en_start++;
    }
  }
}
reset($handle); //把英文剧本指针返回第一个。
//下面是中文
$gb_cc=0;
$gb_start = 0;
$gb_filename = "./gb.txt";
$gb_handle = file($gb_filename);
$gb_new = array();
foreach ($gb_handle as $gb_key => $gb_value)  //$gb_handle是$gb_handle[0]=1 $gb_handle[1]=00:33:47,890 --> 00:33:48,610
{
   
   if(ereg("^[1-9]",$gb_value))
{  
   
    if ($gb_value==($gb_start+1))
    {
     $gb_new[$gb_cc]=$gb_key; //+2是为了把文字部分定位 因为数字和文字差两行。$gb_key+2为txt文本中文字所在的行数。
     $gb_cc++;
     $gb_start++;
    }
   
   
  }
}
reset($gb_handle); //把英文剧本指针返回第一个。

foreach ($gb_new as $new_key => $new_value)  //中文在先$new_value开始于0
{
   $total[$cc_total]=$gb_handle[$new_value];
   $total[$cc_total+1]=$gb_handle[$new_value+1];
   $total[$cc_total+2]=$gb_handle[$new_value+2];
   $total[$cc_total+3]=$gb_handle[$new_value+3];
   //上面四个为中文 INDEX 和时间 和两行内容
   $cc_total=$cc_total+7; //指针移动到$total[7]
}
foreach ($enew as $e_new_key => $e_new_value)
{
   $total[$cc_e_total]=$handle[$e_new_value];
   $total[$cc_e_total+1]=$handle[$e_new_value+1];
   $cc_e_total=$cc_e_total+7;
}
$total_count=count($total);
for($e=0;$e<$total_count;$e++)
{
   
   echo $total[$e]."<br />";

  
}

?>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表