I almost have it but its not working 100%. I would like to strip everything from a string and return only the image URL. If the string has more than one image then it would separate image URL's by a comma ",". I started with this answer and got this far:
Example string (this will change but all I need are the image URL's with a comma delimiter if more than one)
<table border="0" cellpadding="8"><tr><td width="80px"><a href="https://www.ebay.com/itm/Vintage-Elegant-Clear-Glass-Light-Shade-Ceiling-3-holes-Large-Flower/183189652718?hash=item2aa6f444ee:g:ji8AAOSwzpFa20P3"><img border="0" src="https://i.ebayimg.com/thumbs/images/g/ji8AAOSwzpFa20P3/s-l225.jpg"></a></td><td><div><span><strong>$15.00</strong></span></div><div>End Date: <span>May-21 07:03</span></div><div>Buy It Now for only: US $15.00</div><a href="https://www.ebay.com/itm/Vintage-Elegant-Clear-Glass-Light-Shade-Ceiling-3-holes-Large-Flower/183189652718?hash=item2aa6f444ee:g:ji8AAOSwzpFa20P3">Buy it now</a><span> | </span><a href="http://cgi1.ebay.com/ws/eBayISAPI.dll?MfcISAPICommand=MakeTrack&item=183189652718&ssPageName=RSS:B:SHOP:US:104">Add to watch list</a></td></tr></table>
The PHP:
<?php
function getImageUrlFromEbay($content = null) {
if( !empty($content)){
$imgSrc = preg_replace("/(<img\\s)[^>]*(src=\\S+)[^>]*(\\/?>)/i", "$1$2$3", $content);
return $imgSrc;
}
}
?>
Here is a preview of what my current function returns:
How can I make sure the function only returns the image URL's?