the reason you arent getting any results is because weatherzone is blocking
file_get_contents()
.. use cURL and imitate a web browser:
$url="http://www.weatherzone.co.nz/north-island/wellington";
$agent= 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$html = curl_exec($ch);
$doc = new DOMDocument();
$doc->loadHTML($html);
$tags = $doc->getElementsByTagName('img');
foreach ($tags as $tag) {
echo $tag->getAttribute('src');
}
This prints out the
src=""
as you've said, so you need to wrap that in img tags and reference their domain - as the images are stored on their website not yours..
foreach ($tags as $tag) {
echo '<img src="http://www.weatherzone.co.nz' . $tag->getAttribute('src') . '">';
}