php alternative to explode
You should use parse_url(), like this :
$URI_parts = parse_url( $_SERVER['REQUEST_URI'] );echo 'http://' . $_SERVER['SERVER_NAME'] . $URI_parts['path'];
You could use strstr($_SERVER['REQUEST_URI'], "?", TRUE)
. Alternatively, you could use strtok($_SERVER['REQUEST_URI'], "?")
.
It should stop matching after it's satisfied.
As an aside, you shouldn't not use a PHP function because you heard [citation needed] that it was slow. You should use the appropriate tool for the job, and if that's too slow after finding a performance issue, measuring it and determining it's your use of that function, then consider refactoring.