Skip to content

Instantly share code, notes, and snippets.

@kevsersrca
Created February 28, 2018 12:01
Show Gist options
  • Save kevsersrca/b1e7c3aed509df15de6021b285d9dbe2 to your computer and use it in GitHub Desktop.
Save kevsersrca/b1e7c3aed509df15de6021b285d9dbe2 to your computer and use it in GitHub Desktop.
Clean url
public function cleanUrl($url) {
if (strpos($url, 'https://') > -1) {
$clean = array_filter(explode("https://", $url));
return $this->cleanUrl($clean[1]);
}
if (strpos($url, 'http://') > -1) {
$clean = array_filter(explode("http://", $url));
return $this->cleanUrl($clean[1]);
}
if (strpos($url, "/") > -1) {
$clean = array_filter(explode("/", $url));
return $this->cleanUrl($clean[0]);
}
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment