Setting controller, action, and values based on the number of URL chunks Is there any way to improve this code? It looks a bit ugly for me.

if($url_chunks_num == 1) {
    $this-&gt;controller = $this-&gt;pageData[0];
} elseif($url_chunks_num == 2) {
    $this-&gt;controller = $this-&gt;pageData[0];
    $this-&gt;action = $this-&gt;pageData[1];
} elseif($url_chunks_num &gt; 2) {
    $this-&gt;controller = $this-&gt;pageData[0];
    $this-&gt;action = $this-&gt;pageData[1];
    $this-&gt;values = array_slice($this-&gt;pageData, 2);
}


I thought about nested conditions, but this option is ugly as well.
There seems to be some code repetition. Perhaps this could be improved like this:

if ($url_chunks_num &gt;= 1)
   $this-&gt;controller = $this-&gt;pageData[0];
if ($url_chunks_num &gt;= 2)
   $this-&gt;action = $this-&gt;pageData[1];
if ($url_chunks_num &gt; 2)
   $this-&gt;values = array_slice($his-&gt;pageData, 2);


Or

if ($url_chunks_num &gt;= 1) {
   $this-&gt;controller = $this-&gt;pageData[0];
   if ($url_chunks_num &gt;= 2)
      $this-&gt;action = $this-&gt;pageData[1];
   if ($url_chunks_num &gt; 2)
      $this-&gt;values = array_slice($his-&gt;pageData, 2);
}