coder request

2005.12.06

anyone got any stuff already written in php that will search a string for img tags and replace (remove!) them ?

i have a page similar to this at work, however the way the ad-based images in the feeds work, it causes crazy proxy authentication issues. the site logos are enabled at home but not at work. the rss/php processor has an option for that. however, the content providers are embedding image advertisements into their feeds.

each xml feed gets processed and returned to be echo/printed on the screen for the user. before output, i’d like to remove the IMG tags.

i’m thinking i need to:


while loop to see if '{img src=' exists in the string
search the string for the indexof (stripos) for the first '{img src='
return the rest of the string, starting at '{img src='
search for the indexof(stripos) for the next '}'
using substr_replace, replace string between the position of '{img src=' and '}'

any faster ways to accomplish this? 🙂

Categories : geek

one comment

  1. […] i needed to do some PHP image replacement for a personal webpage i maintain at work. while researching the functions to perform the work, i found someone has already done the work for me, i replaced all the {scritpt}{/script} tags with {img}{/img} tags and that works. […]

Leave a comment