title: Load view by current URL last segment in Codeigniter
body: <p>I'm trying to load view content page when url last segment matched. When click a link which get link in url like <code>http://192.168.20.2/vtp/attendance/rawAttendance</code> then load the <code>rawAttendance</code> view and when I click other link which last segment is <code>getAttendance</code> then it's also load the same same view not <code>getAttendance</code>. How do get this done?</p>
  
  <pre><code>    $last = $this-&gt;uri-&gt;total_segments();
      $lastSegment = $this-&gt;uri-&gt;segment($last);
      if ($this-&gt;input-&gt;post("fromAjax")) {
          if($lastSegment == "rawAttendance"){
              $this-&gt;load-&gt;view('attendance/rawAttendance', $data);
          }else if($lastSegment == "getAttendance"){
              $this-&gt;load-&gt;view('attendance/getAttendance', $data);
          }else {
          }
      } 
  </code></pre>