title: Clean URLS in MVC structure using PHP
body: <p>I am creating a website using the MVC structure. Below is a code I have used to use clean URLS and load the appropriate files. However it only works for the first level.</p>
  
  <p>Say I wanted to visit <code>mywebsite.com/admin</code> it would work, however <code>mywebsite.com/admin/dashboard</code> would not. The problem is in the arrays, how could I get the array to load content after the 2nd level along with the second level.</p>
  
  <p>Would it be best to create an array like this?</p>
  
  <pre><code>Array
       - controller
       - view
            - dashboard
  </code></pre>
  
  <p>Any help here would be great. Also as a side question. What would be the best way to set up "custom" urls. So if I were to put in <code>mywebsite.com/announcement</code> it would check to see if its got controllers, failing that, check to see if it's got custom content (maybe a file of the same name in "customs" folder, and then if there's nothing execute the 404 page not found stuff) This isn't a priority question though, but loosely associated in how the code works so I thought it best to add.</p>
  
  <pre><code>function hook() {
      $params = parse_params();
      $url = $_SERVER['REQUEST_URI'];
      $url = str_replace('?'.$_SERVER['QUERY_STRING'], '', $url);
  
      $urlArray = array();
      $urlArray = explode("/",$url);
      var_dump($urlArray);
      if (isset($urlArray[2]) &amp; !empty($urlArray[2])) {
          $route['controller'] = $urlArray[2];
      } else {
          $route['controller'] = 'front'; // Default Action
      }
      if (isset($urlArray[3]) &amp; !empty($urlArray[3])) {
          $route['view'] = $urlArray[3];
      } else {
          $route['view'] = 'index'; // Default Action
      }
      include(CONTROLLER_PATH.$route['controller'].'.php');
      include(VIEW_PATH.$route['controller'].DS.$route['view'].'.php');
      var_dump($route['controller']);
      var_dump($route['view']);
      var_dump($urlArray);
      var_dump($params);
  
      // reseting messages
      $_SESSION['flash']['notice'] = '';
      $_SESSION['flash']['warning'] = '';
  }
  // Return form array
  function parse_params() {
      $params = array();
      if(!empty($_POST)) {
          $params = array_merge($params, $_POST);
      }
      if(!empty($_GET)) {
          $params = array_merge($params, $_GET);
      }
      return $params;
  }
  </code></pre>