• 0
  • 0

将HTML 视频链接的a标记转换成video标记

2020-05-20 59 0 admin 所属分类:PHP 记录
if (preg_match_all('/<a[sS.]+?href=['"]+([sS.]+?)['"]+[sS.]*>.+?</a>/',$content,$data)) {
        foreach ($data[1] as $k => $v) {
                if (strpos($v,'.mp4')!==false || strpos($v,'.rmvb')!==false || strpos($v,'.mkv')!==false || strpos($v,'.wmv')!==false || strpos($v,'.avi')!==false) {
                        $video = '<div style="text-align:center;"><video src="'.$v.'" controls="controls" width="400px" height="400px"></video></div><br/>';
                        $content = str_replace($data[0][$k],$video,$content);
                }
        }
}


返回顶部