php - Getting Image Source from RSS CDATA -


i have function grab image src field cdata in rss feed.

function echo_url($string) {   preg_match_all('#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#', $string, $match);   return $match[0][0]; } 

only bad thing it's picking first url appears in cdata instead of image src itself, there anyway can access or return image src instead of first url?

here's example of cdata get.

![cdata[duration: 357 sec<br>url: http://www.test.com/videos/999682/test-test-video<br><img src="http://test.com/images/test.jpg"><br><iframe src="http://embeds.test.com/embed/999682" frameborder=0 width=650 height=518 scrolling=no></iframe>]] 

all i'm after in getting 'img src'.

any brilliant (bit of beginner @ php)

thanks

if want return image source, function work:

/**  * @param string $cdata  * @return string|false  */ function getimgsrc($cdata) {     $found = preg_match("/img src=\"([^\"]+)\"/", $cdata, $match);     if ($found)     {         return $match[1];     }     else     {         return false;     } } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -