Skip to content

Instantly share code, notes, and snippets.

@matesnippets
Created March 9, 2015 14:59
Show Gist options
  • Select an option

  • Save matesnippets/c974fa8f7dcfc0e3a9f0 to your computer and use it in GitHub Desktop.

Select an option

Save matesnippets/c974fa8f7dcfc0e3a9f0 to your computer and use it in GitHub Desktop.
PHP, Strip http, https, and www. from URL
/**
* Strips http:// and https:// and www. and the trailing slash / from URL
* @param string $url The URL to be processed
* @return string Modified URL
*/
function strip_crap_from_url($url)
{
return preg_replace('/https?:\/\/|www.|\/$/', '', $url);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment