1
我有这样的iframe如何从YouTube的iframe中获取的视频ID在PHP或CakePHP的
<iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe>
如何从它的正则表达式或获得视频ID .....
我有这样的iframe如何从YouTube的iframe中获取的视频ID在PHP或CakePHP的
<iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe>
如何从它的正则表达式或获得视频ID .....
你可以使用方法:
$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);
$子模式将包含:
Array ([0] => http://www.youtube.com/embed/YRUG-Pu7RzE [1] => YRUG-Pu7RzE)
我不是高兴的语法突出。这可以改善吗? – Leif