0

I need to extract following url using php : "http://www.website.com/profile#username". All the methods that I have tried return "http://www.website.com/profile"

1 Answers1

2

Just use parse_url()

$url = 'http://www.website.com/profile#username';
$parse = parse_url($url);
print $parse['host']; // prints 'website.com'
Peyman.H
  • 1,819
  • 1
  • 16
  • 26