Forum Moderators: coopster
If a link is <a href="blabla.pdf">Bla Bla</a>, then directly after it automatically posting the img code for a PDF icon image. (or excel icon, or word icon etc.)
Any direction in how to achieve this would be much appreciated.
Thank you
Are you creating (ie. writing out) your links with PHP when you create your page? If not, then I would consider using JavaScript (link to forum) [webmasterworld.com] instead of PHP to solve this problem. I would have thought that using JS you could more easily step through the DOM and add the appropriate CLASS attributes to the anchors. JS would be OK in this case since the icon is really only a presentational 'nice to have' and does not necessarily add to the page content, so it would not matter if the JS did not run on a device that did not have JS enabled. It could also be a useful function to add to your JS library that you could call on any page that required file-type icons on links.
Sorry for the narrative, I just don't think that PHP is the right tool for the job in this case. Unless you are writing the links themselves with PHP...?