Created
March 9, 2015 14:59
-
-
Save matesnippets/c974fa8f7dcfc0e3a9f0 to your computer and use it in GitHub Desktop.
PHP, Strip http, https, and www. from URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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