我想从一个object/embed html源获取视频网址.我读过我可以使用正则表达式来获取它,但我和正则表达式不是朋友
以下是我所拥有的:
<?php
function src($text) {
$text = str_replace('"', '', $text);
$text = str_replace('src=', '', $text);
$temporary = explode('<embed', $text);
$temporary = $temporary[1];
$temporary = explode(' ', trim($temporary));
return $temporary[0];
}
$html = '
<object width="180" height="220">
<param name="movie" value="http://www.domain.com/video/video1.swf"></param>
<embed src="http://www.domain.com/video/video1.swf" type="application/x-shockwave-flash" width="180" height="220"></embed>
</object>
';
echo src($html);
Run Code Online (Sandbox Code Playgroud)
这有效,但正则表达式更好吗?
我正在使用灯