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? Quote Link to comment Share on other sites More sharing options...
boo_lolly Posted April 11, 2007 Share Posted April 11, 2007 you need str_replace() Quote Link to comment 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 Quote Link to comment 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 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.