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));
}
精彩评论