Dynamically replace the

Loyd

New Member
\[quote\] Possible Duplicate:
Dynamically replace the “src” attributes of all <img> tags \[/quote\]Funny story: I posted this very question a short time ago, but instead of getting something I could, you know, use, all I got was a lot of dogma about the evils of using regex to parse HTML. So here goes again.I have some HTML and want to replace the "src" attributes of all the img tags so that they point to copies of the identical images (although with different file names) on another host.For instance, given these three tags\[code\]<IMG SRC="http://stackoverflow.com/questions/graphics/pumpkin.gif" ALT="pumpkin"><IMG BORDER="5" SRC="http://stackoverflow.com/questions/3808746/redball.gif" ALT="*"> <img alt="cool image" src="http://www.crunch.com/pic.jpg"/>\[/code\]I would like them replaced with\[code\]<IMG SRC="http://myhost.com/cache/img001.gif" ALT="pumpkin"><IMG BORDER="5" SRC="http://myhost.com/cache/img002.gif" ALT="*"> <img alt="cool image" src="http://myhost.com/cache/img003.jpg"/>\[/code\]I am trying to use PHP Simple HTML DOM Parser, but I'm not getting it. \[code\]include 'simple_html_dom.php';$html = str_get_html('<html><body><IMG SRC="http://stackoverflow.com/questions/graphics/pumpkin.gif" ALT="pumpkin"><IMG BORDER="5" SRC="http://stackoverflow.com/questions/3808746/redball.gif" ALT="*"> <img alt="cool image" src="http://www.crunch.com/pic.jpg"/></body></html>');\[/code\]What do I do next?
 
Back
Top