I'm trying to get image address from a img tag in PHP. this is a HTML page:
<div class="image">
<a href="http://mywebpage.com/">
<img height="317" width="214" alt="Photo" title="Photo" src="http://mydomain.com/image.jpg" itemprop="image">
</a>
</div>
The PHP Part:
$text = file_get_contents("http://www.mydomain.com/page.html");
//i Tried This One:
preg_match_all('/<div class=\"image\">(.*?)<\/div>/s', $text, $out);
//And This one
preg_match('/~src="(.*)"itemprop="image" \/>/',$text,$out);
//Print
print_r($out);
Problem is, i can't fetch the image address only! i searched in Google and Stack Overflow and tried some codes.
I hope you guys help me with that problem.