-2
if(isset($_SERVER['HTTP_REFERER'])) {
    $sitio = $_SERVER['HTTP_REFERER'];
}

I need to split $sitio so i have "example" instead of "http://example.com/subfolder" or "http://www.example.com/subfolder"!

Francisco
  • 254
  • 3
  • 9
  • 1
    google "split url php" (this is a very basic question, that can easily be answered by google (or even better, searching on php.net)) – cypherabe Oct 30 '14 at 15:10

1 Answers1

4

You can use parse_url.

if(isset($_SERVER['HTTP_REFERER'])) {
    $sitio = parse_url($_SERVER['HTTP_REFERER'])['host'];
}
ʰᵈˑ
  • 11,279
  • 3
  • 26
  • 49