Skip to content

Instantly share code, notes, and snippets.

@brandon-braner
Created October 18, 2016 15:42
Show Gist options
  • Save brandon-braner/57becdf5ef06604d0230e87a9602130b to your computer and use it in GitHub Desktop.
Save brandon-braner/57becdf5ef06604d0230e87a9602130b to your computer and use it in GitHub Desktop.
function parse_request() {
// get current url
$current = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// calculate the path
$part = substr( $current, strlen( site_url() ) );
if ( $part[0] == '/' ) {
$part = substr( $part, 1 );
}
// strip parameters
$real = explode( '?', $part );
foreach($real as $index => $token){
//decode url enteities such as %20 for space
$tokens[$index] = urldecode($token);
}
return $tokens;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment