An open API service indexing awesome lists of open source software.

https://github.com/nggit/php-simple-uri-router

A Simple URI Router
https://github.com/nggit/php-simple-uri-router

Last synced: about 1 month ago
JSON representation

A Simple URI Router

Awesome Lists containing this project

README

          

# PHP Simple URI Router Quick Tour
**Tip:** Rename this `md` file to `php` to test it on your web server.

parse($uri);

### Get the first uri segment
echo $path->first(); // fruit.name
echo '
';

### Get the first uri segment, before certain token
echo $path->first('.?&'); // fruit
echo '
';

### Get an uri segment after another segment
echo $path->after('apple'); // banana
echo '
';

### Get n uri segment after another segment
echo $path->after('apple', 2); // banana/melon
echo '
';

### Get all uri segment after another segment
echo $path->after('apple', null); // banana/melon/orange.html
echo '
';

### Get an uri segment after another segment, before certain token
echo $path->after('melon', 1, '.?&'); // orange
exit;

?>

Note that one or more empty uri segment will be skipped, e.g. `apple//banana`, `$path->after('apple')` will return banana.