public function reverseRoute(string $search, ...$params)
	{
		// Named routes get higher priority.
		foreach ($this->routes as $verb => $collection)
		{
			if (array_key_exists($search, $collection))
			{
				return $this->fillRouteParams(key($collection[$search]['route']), $params);
			}
		}

		// If it's not a named route, then loop over
		// all routes to find a match.
		foreach ($this->routes as $verb => $collection)
		{
			foreach ($collection as $route)
			{
				$from = key($route['route']);
				$to   = $route['route'][$from];

				// Lose any namespace slash at beginning of strings
				// to ensure more consistent match.
				$to     = ltrim($to, '\\');
				$search = ltrim($search, '\\');

				// If there's any chance of a match, then it will
				// be with $search at the beginning of the $to string.
				if (strpos($to, $search) !== 0)
				{
					continue;
				}

				// Ensure that the number of $params given here
				// matches the number of back-references in the route
				if (substr_count($to, '$') !== count($params))
				{
					continue;
				}

				return $this->fillRouteParams($from, $params);
			}
		}

		// If we're still here, then we did not find a match.
		return false;
	}
public function reverseRoute(string $search, ...$params)
	{
		// Named routes get higher priority.
		foreach ($this->routes as $verb => $collection)
		{
			if (array_key_exists($search, $collection))
			{
				return $this->fillRouteParams(key($collection[$search]['route']), $params);
			}
		}

		// If it's not a named route, then loop over
		// all routes to find a match.
		foreach ($this->routes as $verb => $collection)
		{
			foreach ($collection as $route)
			{
				$from = key($route['route']);
				$to   = $route['route'][$from];

				// Lose any namespace slash at beginning of strings
				// to ensure more consistent match.
				$to     = ltrim($to, '\\');
				$search = ltrim($search, '\\');

				// If there's any chance of a match, then it will
				// be with $search at the beginning of the $to string.
				if (strpos($to, $search) !== 0)
				{
					continue;
				}

				// Ensure that the number of $params given here
				// matches the number of back-references in the route
				if (substr_count($to, '$') !== count($params))
				{
					continue;
				}

				return $this->fillRouteParams($from, $params);
			}
		}

		// If we're still here, then we did not find a match.
		return false;
	}
public function reverseRoute ( string $ search , ... $ params ) { // Named routes get higher priority. foreach ( $ this -> routes as $ verb => $ collection ) { if ( array_key_exists ( $ search , $ collection ) ) { return $ this -> fillRouteParams ( key ( $ collection [ $ search ] [ 'route' ] ) , $ params ) ; } } // If it's not a named route, then loop over // all routes to find a match. foreach ( $ this -> routes as $ verb => $ collection ) { foreach ( $ collection as $ route ) { $ from = key ( $ route [ 'route' ] ) ; $ to = $ route [ 'route' ] [ $ from ] ; // Lose any namespace slash at beginning of strings // to ensure more consistent match. $ to = ltrim ( $ to , '\\' ) ; $ search = ltrim ( $ search , '\\' ) ; // If there's any chance of a match, then it will // be with $search at the beginning of the $to string. if ( strpos ( $ to , $ search ) !== 0 ) { continue ; } // Ensure that the number of $params given here // matches the number of back-references in the route if ( substr_count ( $ to , '$' ) !== count ( $ params ) ) { continue ; } return $ this -> fillRouteParams ( $ from , $ params ) ; } } // If we're still here, then we did not find a match. return false ; }
Attempts to look up a route based on it's destination.

If a route exists:

'path/(:any)/(:any)' => 'Controller::method/$1/$2'

This method allows you to know the Controller and method
and get the route that leads to it.

// Equals 'path/$param1/$param2'
reverseRoute('Controller::method', $param1, $param2);

@param string $search
@param array  ...$params

@return string|false
Attempts to look up a route based on it s destination .