Reputation: 441
<html>
<body>
<?php
$html='<html>
<body>
<p>
Illustrating wget -r , with images too
</p>
<p>
This is the first image
<img src="abc.JPG" alt="First Captured Image"/>
</p>
<p>
This is the second image
<img src="def.JPG" alt="Second Captured Image"/>
</p>
</body>
</html>';
echo($html);
$dom = new domDocument;
@$dom->loadHTML($html);
$dom->preserveWhiteSpace = false;
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
echo $image->getAttribute('src');
echo $alter->get Attribute('alt');
echo "<img sr='$image'/>";
}
</body>
</html>
My code is to parse the images in the html code above and then use php to echo it again. This is my sample code. How do I echo the above html code, using php, and display in the same way?
I tried doing this, but I cant place image in exactly the same position as where I retrieved. I don't want to use "header(contents)"
Upvotes: 0
Views: 106
Reputation: 2630
Your statement echo "<img sr='$image'/>";
is incorrect. The correct one is
echo "<img src='$image'/>";
Upvotes: 1