raimis100 Posted September 23, 2008 Share Posted September 23, 2008 Hi! I need to think a way how to delete all hrefs from text and leave only text which was as anchor Here is <*a href="h*ttp://phpfreaks.com/" forum </*a> It should be like: Here is forum Please , someone help me out here Quote Link to comment https://forums.phpfreaks.com/topic/125468-solved-strip-put-all-hrefs/ Share on other sites More sharing options...
effigy Posted September 23, 2008 Share Posted September 23, 2008 Will strip_tags work for you? Quote Link to comment https://forums.phpfreaks.com/topic/125468-solved-strip-put-all-hrefs/#findComment-648652 Share on other sites More sharing options...
raimis100 Posted September 23, 2008 Author Share Posted September 23, 2008 strip_tags strips out all the tags only leaving those I add but that will not work since I am working with website pages and there are more unique tags than I could add. Googling right now. Maybe I will find already made function edit:nah, I guess I will not find it anywhere. I would still be thankfull for some help Quote Link to comment https://forums.phpfreaks.com/topic/125468-solved-strip-put-all-hrefs/#findComment-648661 Share on other sites More sharing options...
effigy Posted September 23, 2008 Share Posted September 23, 2008 echo preg_replace('%</?a(?(?<=<a)[^>]*)>%', '', $data); Quote Link to comment https://forums.phpfreaks.com/topic/125468-solved-strip-put-all-hrefs/#findComment-648670 Share on other sites More sharing options...
raimis100 Posted September 23, 2008 Author Share Posted September 23, 2008 Works perfect! Thanks a much! Last time I looked at regex tuts they scared me. I hope tha one day I will learn it too Quote Link to comment https://forums.phpfreaks.com/topic/125468-solved-strip-put-all-hrefs/#findComment-648672 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.