For the request object in my PHP application, I need to dissect the URL and assign its components to my class attributes (module, controller, method and the rest are parameters). Currently, I'm doing it like the following but that looks really ugly to me. Is there a better way to do it?
$urlComponents = explode('/', $requestUrl);
if(isset($urlComponents[0]))
{
$this->_module = array_shift($urlComponents);
if(isset($urlComponents[0]))
{
$this->_controller = array_shift($urlComponents);
if(isset($urlComponents[0]))
{
$this->_method = array_shift($urlComponents);
if(isset($urlComponents[0]))
{
$this->_params = $urlComponents;
}
}
}
}