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"
Asked
Active
Viewed 59 times
0
-
2what is the final string that u want??? – Peyman.H Aug 30 '15 at 11:12
-
1possible duplicate of [Getting FULL URL with #tag](http://stackoverflow.com/questions/6119095/getting-full-url-with-tag) – Syakur Rahman Aug 30 '15 at 11:40
1 Answers
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