0
<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)"

1
  • 2
    You'll have to modify the DOM structure to get things to print in particular places. So take out the echos inside the loop, and add nodes there with what you want to print. Commented May 4, 2012 at 6:02

1 Answer 1

1

Your statement echo "<img sr='$image'/>"; is incorrect. The correct one is

echo "<img src='$image'/>"; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.