Jump to content

function to strip a website url


brown2005

Recommended Posts

function url_strip($url){
return preg_replace('#^https?://www.#', '', $url);
}

 

I currently have the above function witch strips say http://www.thiswebsite.co.uk into thiswebsite.co.uk

 

what I want to do is add

 

 

$remove = array('https://www.','http://www.','https://','http://','www.');

 

this into the function, I have tried

 

 


function url_strip($url){

  $remove = array('https://www.','http://www.','https://','http://','www.');

foreach($remove as $key => $val){

$array[$key] = preg_replace(''.$val.'','', $url);

}

return $url;

}

Link to comment
https://forums.phpfreaks.com/topic/274111-function-to-strip-a-website-url/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.