public function matches($uri)
    {
        if (!preg_match($this->compiledRegex, $uri, $matches)) {
            return false;
        }

        $params = array();
        foreach ($matches as $key => $value) {

            /** gestion des sous-repertoires : uniquement si controller contient des _ */
            if ($key == 'controller' && substr_count($value, '_')) {
                $temp = explode('_', $value);
                $value = array_pop($temp);
                $params['directory'] = implode('/', $temp);
            }
            // Set the value for all matched keys
            $params[$key] = $value;
        }

        return array_merge($this->defaults, $params);
    }
public function matches($uri)
    {
        if (!preg_match($this->compiledRegex, $uri, $matches)) {
            return false;
        }

        $params = array();
        foreach ($matches as $key => $value) {

            /** gestion des sous-repertoires : uniquement si controller contient des _ */
            if ($key == 'controller' && substr_count($value, '_')) {
                $temp = explode('_', $value);
                $value = array_pop($temp);
                $params['directory'] = implode('/', $temp);
            }
            // Set the value for all matched keys
            $params[$key] = $value;
        }

        return array_merge($this->defaults, $params);
    }
public function matches ( $ uri ) { if ( ! preg_match ( $ this -> compiledRegex , $ uri , $ matches ) ) { return false ; } $ params = array ( ) ; foreach ( $ matches as $ key => $ value ) { /** gestion des sous-repertoires : uniquement si controller contient des _ */ if ( $ key == 'controller' && substr_count ( $ value , '_' ) ) { $ temp = explode ( '_' , $ value ) ; $ value = array_pop ( $ temp ) ; $ params [ 'directory' ] = implode ( '/' , $ temp ) ; } // Set the value for all matched keys $ params [ $ key ] = $ value ; } return array_merge ( $ this -> defaults , $ params ) ; }
Tests if the route matches a given URI. A successful match will return
all of the routed parameters as an array. A failed match will return
boolean FALSE.

// This route will only match if the <controller>, <action>, and <id> exist
$params = self::factory('<controller>/<action>/<id>', array('id' => '\d+'))
->matches('users/edit/10');
// The parameters are now: controller = users, action = edit, id = 10

This method should almost always be used within an if/else block:

if ($params = $route->matches($uri))
{
// Parse the parameters
}

@param string $uri URI to match
@return FALSE
Tests if the route matches a given URI . A successful match will return all of the routed parameters as an array . A failed match will return boolean FALSE .