ilikemath2002 Posted February 7, 2009 Share Posted February 7, 2009 What's the easiest way to remove http://, www, or both from user inputted content? Quote Link to comment https://forums.phpfreaks.com/topic/144226-solved-removing-http-or-www-or-both/ Share on other sites More sharing options...
.josh Posted February 7, 2009 Share Posted February 7, 2009 $string = preg_replace("~(http://|www\.)~","", $string); might be faster to use two str_replaces though: $remove = array('http://','www.'); foreach($remove as $r) { $string = str_replace($r,'',$string); } You can benchmark it yourself if you really want to know. Quote Link to comment https://forums.phpfreaks.com/topic/144226-solved-removing-http-or-www-or-both/#findComment-756867 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.