jakebur01 Posted May 30, 2008 Share Posted May 30, 2008 How do I prevent people from displaying html links in their descriptions. I want to replace all html in the description with nothing before it is displayed on the website. thanks, jake Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/ Share on other sites More sharing options...
.josh Posted May 30, 2008 Share Posted May 30, 2008 regex Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/#findComment-553689 Share on other sites More sharing options...
jakebur01 Posted May 30, 2008 Author Share Posted May 30, 2008 could i do something like: $sambo = "Visit us at <a ahef="http://www.oursite.com">"; $sambo = preg_replace ("<a ahef=", " ", $sambo); $sambo = preg_replace (">", " ", $sambo); Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/#findComment-553700 Share on other sites More sharing options...
.josh Posted May 30, 2008 Share Posted May 30, 2008 I'd go for something that removes everything between the < > Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/#findComment-553705 Share on other sites More sharing options...
thebadbad Posted May 30, 2008 Share Posted May 30, 2008 strip_tags() ? Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/#findComment-553732 Share on other sites More sharing options...
rarebit Posted May 30, 2008 Share Posted May 30, 2008 Here's my start: $s = "This is my web address <a href='here.com'>here</a>, This is my web address <a href='here.com'>here</a>"; $pattern = array('/\<a([\w\W]*)\>([\w\W]*)\<\/a\>/isU'); $replacement = array('***'); $ss = preg_replace($pattern, $replacement, $s); print "orig: ".$s."<br>"; print "alt: ".$ss."<br>"; Link to comment https://forums.phpfreaks.com/topic/108026-removing-links-from-descriptions/#findComment-553793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.