开发者

parsing url from embed code in php?

I want to parse the url from the embed code :

<embed src="http://url/player.swf" width="360" height="240" />

It's extracted from my db and put into a variable... How do i parse the url??

any help appreciated..

Edit:

I should probably add that the url in the embed code wnt always be the same (on different pages)... as it's been taking 开发者_StackOverflow中文版from the db


start by exploding the string

$theString = '<embed src="http://url/player.swf" width="360" height="240" />';

$arrString = explode('"', $theString);

$yourURL = $arrString[1];


Try:

<?php
$str = '<embed src="http://url/player.swf" width="360" height="240" />';

if (preg_match('!<embed[^>]+src="([^"]+)"[^>]+/>!', $str, $matches)) {
    $src = $matches[1];
    print_r(parse_url($src));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜