public function video_h(){
$sql = "select h.title,d.content from v9_hjxy_data as d,v9_hjxy as h where d.id=h.id and h.wzlb='视频' and h.id<60 ";
$rs = $this->db->query($sql);
$list = $rs->result_array();
foreach($list as $r){
$str = $this->video_s($r['content']);
if($str){
echo $r['title'].'<br>';
echo $str.'<br>';
}
}
}
public function video_s($str){
$preg_tudou = '/(tudou)/is';
$preg_qq = '/(qq)/is';
$preg_em_qq = '/(<embed.*vid=)(.*?)(&.*<\/embed>)/is';
$preg_em_youku = '/(<embed.*src\=\"http.*\/)(.*?)(\/v.swf)(\".*<\/embed>)/is';
$preg_ob_youku = '/(<object.*src\=\"http.*\/)(.*?)(\/v.swf)(\".*<\/object>)/is';
if(preg_match_all($preg_em_qq,$str,$arr) and !preg_match($preg_tudou,$str) and preg_match($preg_qq,$str)){
$str = preg_replace($preg_em_qq,'<iframe height=498 width=510 src="http://v.qq.com/iframe/player.html?vid=\\2" frameborder=0 allowfullscreen></iframe>',$str);
return $str;
}elseif(preg_match_all($preg_ob_youku,$str,$arr) and !preg_match($preg_tudou,$str) and !preg_match($preg_qq,$str)){
$str = preg_replace($preg_ob_youku,'<iframe height=498 width=510 src="http://player.youku.com/embed/\\2" frameborder=0 allowfullscreen></iframe>',$str);
return $str;
}elseif(preg_match_all($preg_em_youku,$str,$arr) and !preg_match($preg_tudou,$str) and !preg_match($preg_qq,$str)){
$str = preg_replace($preg_em_youku,'<iframe height=498 width=510 src="http://player.youku.com/embed/\\2" frameborder=0 allowfullscreen></iframe>',$str);
return $str;
}
}
优酷、腾讯视频分享代码html替换通用
最新推荐文章于 2021-06-08 13:54:07 发布