Looking for a way of getting the path from an URL in PHP:
I want to take: http://example.com/hurrdurr
http://example.com/hurrdurr
And make it: hurrdurr
hurrdurr
Use parse_url to extract the information you want.
For instance:
$url = "http://twitter.com/pwsdedtch"; $path = parse_url($url, PHP_URL_PATH); // gives "/pwsdedtech" $pathWithoutSlash = substr($path, 1); // gives "pwsdedtech"