This code shows how to strip http, www, or any suffixes. The most efficient way is to toss an array at str_replace. If anyone write this will all the suffixes please post in comments!
function remove_http($url){
$remove = array('http://','https://','www.','.com','.org','.net','.co.uk','.name','.info','.cc','.biz','.us','.gb','.tt');
$stripedUrl = str_replace($remove, '', $url);
return strtolower($stripedUrl);
}
Example:
<? echo remove_http("http://www.DesignCodeExecute.com") ?>
Result:
designcodeexecute
0 comments ↓
If you found this post useful click the share this button. Contribute below by adding a comment, no registration is required.
DCE Related Posts
Read Full Article...
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment