Better way to code this?
<p>What would be the best, simplest way to code this:
I have a php document that gets most of the page requests (set up in routes config, using code igniter framework) and depending on the uri i want to show the user different content. Example:</p>

<pre><code>http: // domain.tld/2010/  
Should show one type of content

http: // domain.tld/2010-nov/  
should show another type of content

http: // domain.tld/2010-nov-10/  
should show yet another type of content

http: // domain.tld/2010-nov-10-blog-post-title/  
should show once again another type of content
</code></pre>

<p>Everything else should be treated as if is a product, example:<br>
http: // domain.tld/light-bulb/<br>
and if such a product doesnt exist, its a 404</p>

<p>Below is the code I got at the moment, but I feel it is way too messy. Any suggestion how to make it simpler and more effective? (Tried to get it formatted correctly here but it seem a bit tricky to get code to align properly, a apologize)</p>

<p>Regards,
Jason<br>
(had to add spaces in all my urls here because im new and not allowed to post that many urls)</p>

<pre><code>$val is the uri (/2010-nov.......)

    function show_what($val){
 $arr=array("jan"=&gt;01,"feb"=&gt;02,"mar"=&gt;03,"apr"=&gt;04,"may"=&gt;05,"jun"=&gt;06,"jul"=&gt;07,"aug"=&gt;08,"sep"=&gt;09,"oct"=&gt;10,"nov"=&gt;11,"dec"=&gt;12);
 // first check to see if the uri starts with a year (4 digits)
 if(is_int((int)substr($val,0,4)) &amp;&amp; (int)substr($val,0,4)!=0){
  // Get all posts for specified YEAR
  if(strlen($val)==4){
   // Show all blog posts for specified year
   // example: http: // domain.tld/2010/

  // Get all posts for specified YEAR and MONTH
  }elseif(strlen($val)==8 &amp;&amp; substr($val,4,1)=="-" &amp;&amp; array_key_exists(substr($val,5,3),$arr)){
   // show all blog posts for specified year and month
   // example: http: // domain.tld/2010-nov/

  // Get all posts for specified YEAR, MONTH and DAY OR! get specified post
  }elseif(strlen($val)&gt;=11 &amp;&amp; substr($val,4,1)=="-" &amp;&amp; array_key_exists(substr($val,5,3),$arr) &amp;&amp; substr($val,8,1)=="-" &amp;&amp; is_int((int)substr($val,9,2)) &amp;&amp; (int)substr($val,9,2)!=0){

   // Get all posts for specified YEAR, MONTH and DAY
   if(strlen($val)==11){
    // show all blog posts for specified year, month and day
    // example: http: // domain.tld/2010-nov-10/

   // Get specified post
   }elseif(substr($val,11,1)=="-"){
    // show specified post or 404
    // example: http: // domain.tld/2010-nov-10-blog-post-title/
   }else{
    // "Not a valid article url&lt;Br/&gt;";
    // example: http: // domain.tld/2010-nov-10there-is-a-dash-missing-after-day/
   }
  }else{
   // 404, not a real date
  }
 }else{
  // show product with current uri or if it doesnt exist, 404.
 }
}
</code></pre>
