Skip to content

Instantly share code, notes, and snippets.

@steveathon
Created August 18, 2014 12:32
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steveathon/c48b1b4eea5d8c5aa093 to your computer and use it in GitHub Desktop.
Save steveathon/c48b1b4eea5d8c5aa093 to your computer and use it in GitHub Desktop.
Explode PHP $_SERVER['REQUEST_URI'];
<?php
$URIParts = explode('?',$_SERVER['REQUEST_URI']);
$URI = explode('/',$URIParts[0]);
// Shift the array, to move it past the 'root'
@array_shift($URI);
// Now, get rid of any pesky empty end slashes
while ( @count($URI) > 0 && !end($URI) ) {
@array_pop($URI);
}
print_r($URI);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment