CI_URI::rsegment PHP Method

rsegment() public method

Returns the re-routed URI segment (assuming routing rules are used) based on the index provided. If there is no routing, will return the same result as CI_URI::segment().
See also: CI_URI::$rsegments
See also: CI_URI::segment()
public rsegment ( integer $n, mixed $no_result = NULL ) : mixed
$n integer Index
$no_result mixed What to return if the segment index is not found
return mixed
    public function rsegment($n, $no_result = NULL)
    {
        return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
    }

Usage Example

Example #1
0
 public function rsegment($n, $no_result = NULL)
 {
     if (!is_numeric($n)) {
         if (array_key_exists($n, $this->uri_parameters)) {
             $n = $this->uri_parameters[$n];
         } else {
             return $no_result;
         }
     }
     return parent::rsegment($n, $no_result);
 }