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? 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. 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
Archived
This topic is now archived and is closed to further replies.