slough Posted April 23, 2008 Share Posted April 23, 2008 I have this HTML-code: <img id="ff_header" src="/files/imce_images/image_file.jpg" height="400" width="400" /> ...and want to replace it with this: <a href="/url/to/page"><img id="ff_header" src="/files/imce_images/image_file.jpg" height="400" width="400" /></a> Should I use preg_replace()? How do I solve this? Cheers! Quote Link to comment Share on other sites More sharing options...
aCa Posted April 23, 2008 Share Posted April 23, 2008 You could use somthing like this: preg_replace('/(<img[^>]+>)/i', '<a href="/url/to/page">$1</a>', '<img id="ff_header" src="/files/imce_images/image_file.jpg" height="400" width="400" />'); Quote Link to comment Share on other sites More sharing options...
slough Posted April 23, 2008 Author Share Posted April 23, 2008 Problem solved. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.