如何从php或cakephp中的youtube的iframe获取视频ID [英] how to get Video id from iframe of youtube in php or cakephp
本文介绍了如何从php或cakephp中的youtube的iframe获取视频ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个iframe
i have this iframe
<iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe>
如何通过正则表达式获取视频ID或任何.....
how to get video id from it by regular expression or any.....
推荐答案
您可以使用:
$subject = '<iframe width=\"425\" height=\"349\" src=\"http://www.youtube.com/embed/YRUG-Pu7RzE\" frameborder=\"0\" allowfullscreen></iframe>';
$pattern = '!http://(?:www.)?youtube.com/embed/([^"']+)!i';
$result = preg_match($pattern, $subject, $subpattern);
$ subpattern将包含:
$subpattern will contain:
Array ( [0] => http://www.youtube.com/embed/YRUG-Pu7RzE [1] => YRUG-Pu7RzE )
这篇关于如何从php或cakephp中的youtube的iframe获取视频ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文