I've created this router for my framework and wanted to get some feedback on if it's the most efficient way to search the routes.The main routerpublic static function route($modules = true){    $route = (isset($_GET['route']) && $_GET['route'] != '') ? trim($_GET['route'], '/') : '/';    $parts = explode('/', $route);    if($parts[0] == 'debug' && ENVIROMENT == 'development'){        array_shift($parts);        static::$debug = true;    }    unset($_GET['route']);    if($route != '/' && count($parts) != 0){        static::$routeParts = $parts;        if($parts[0] == 'modules' && $modules){            $path = null;            $fullpath = md5('/'.implode('/', $parts));            //exact match            $pathFound = key_exists($fullpath, static::$routingTable);            //if full path not found look for partial             if(!$pathFound){                $elements = count($parts);// - 2;//parts after the module name                $bits = $parts;                if($elements > 0){                    //array_pop($bits); //remove the final element - wildcard                    $paths = array();                    for($i = 0; $i < $elements; $i++){                        $searchPath = '/'.implode('/', $bits).'/*';                        $paths[] = $searchPath;                        foreach(static::$routingTable as $rt){                            if($searchPath == $rt['path']){                                $pathFound = true;                                $path = $rt;                                break;                            }                        }                        if($pathFound)                            break;                        else                            array_pop($bits);                    }                    /*if($pathFound !== true){                        //match base module and send rest as params                        $moduleSlug = $parts[1];                        $fullpath = md5('/modules/'.$parts[1]);                        $pathFound = key_exists($fullpath, static::$routingTable);                        $path = static::$routingTable[$fullpath];                    }*/                }                else{                    $fullpath = md5('/'.implode('/', $parts).'/*');                    $pathFound = key_exists($fullpath, static::$routingTable);                    $path = static::$routingTable[$fullpath];                }            }            else                $path = static::$routingTable[$fullpath];            array_shift($parts);            array_shift($parts);            if($pathFound){                static::$view = 'view';                static::$args['dir'] = $path['callback']['config']['directory'];                static::$args['slug'] = $parts;                $_GET['params'] = $parts;                static::$args['module'] = true;                static::$args['fullwidth'] = (isset($path['callback']['config']['fullwidth']) ? $path['callback']['config']['fullwidth'] : false);                ModuleLoader::runModule($path);            }            else{                //not ideal                static::$view = '404';                static::$args['fullwidth'] = true;            }        }        else{            static::$view = $parts[0];            array_shift($parts);            array_shift($parts);            static::$args['slug'] = $parts;            $_GET['params'] = $parts;        }    }    else{        //home page module        static::$view = 'index';        static::$args['fullwidth'] = true;    }    static::$routed = true;}Some examples routes added are which will all be pre-pended with site directory + '/modules/' ://test/test//test/*
Modular dynamic based routing with wildcards
mvc;php5