我有这个iframe
<iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe>
如何通过正则表达式或任何.....
从中获取视频ID答案 0 :(得分:0)
您可以使用:
$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将包含:
Array ( [0] => http://www.youtube.com/embed/YRUG-Pu7RzE [1] => YRUG-Pu7RzE )