Skip to content

Instantly share code, notes, and snippets.

@kemo
Created June 17, 2011 13:15
Show Gist options
  • Save kemo/1031396 to your computer and use it in GitHub Desktop.
Save kemo/1031396 to your computer and use it in GitHub Desktop.
Request::process_uri()
<?php
/**
* Process URI
*
* @param string $uri URI
* @param array $routes Route
* @return array
*/
public static function process_uri($uri, $routes = NULL)
{
// Load routes
$routes = (empty($routes)) ? Route::all() : $routes;
$params = NULL;
foreach ($routes as $name => $route)
{
// We found something suitable
if ($params = $route->matches($uri))
{
return array(
'params' => $params,
'route' => $route,
);
}
}
return NULL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment