开发者

parsing url from embed code in php?

开发者 https://www.devze.com 2023-02-24 07:52 出处:网络
I want to parse the url from the embed code : <embed src=\"http://url/player.swf\" width=\"360\" height=\"240\" />

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

精彩评论

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