karthikeyan_coder Posted April 11, 2007 Share Posted April 11, 2007 Hello, I am parsing a rss. While parsing i am getting some images inside the description. Actually i dont want it. so i try to remove <img tags. $desc = "this is the sample image <img src='image.jpg'> have a look on it"; I need $desc like "this is the sample image <!-- <image src='image.jpg'> --> have a look on it" any help? Link to comment https://forums.phpfreaks.com/topic/46637-remove-a-html-tag-in-a-string/ Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 you need str_replace() Link to comment https://forums.phpfreaks.com/topic/46637-remove-a-html-tag-in-a-string/#findComment-227121 Share on other sites More sharing options...
per1os Posted April 11, 2007 Share Posted April 11, 2007 http://us.php.net/manual/en/function.strip-tags.php $desc = "this is the sample image <img src='image.jpg'> have a look on it"; $desc = strip_tags($desc, '<a><p><br>'); // the second param is for allowable tags. However this will remove that reference completely. If you want to replace it with how you have it above, I would suggest ereg_replace and use regex to replace the content. www.php.net/ereg_replace www.php.net/regex Link to comment https://forums.phpfreaks.com/topic/46637-remove-a-html-tag-in-a-string/#findComment-227126 Share on other sites More sharing options...
karthikeyan_coder Posted April 11, 2007 Author Share Posted April 11, 2007 Thanks for the replies.. i got something while googling... http://au3.php.net/manual/en/function.preg-replace.php#59960 now i can remove the unwanted tags from the variable $allowedTags Thanks Link to comment https://forums.phpfreaks.com/topic/46637-remove-a-html-tag-in-a-string/#findComment-227128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.