title: How to truncate a string in codeigniter view
body: <p>here is my controller which will get the url information from some model function and passed it to my view.</p>
  
  <pre><code>class MyController extends CI_Controller{
  
      public function __construct()
      {
          parent::__construct();
  
          //load the settings model
          //some model
  
          //load the text helper
          $this-&gt;load-&gt;helper('text');
      }
  
      public function index()
      {
  
          //call the model function to get the Url data
          $data['urllist'] = //call the model function and get the array and store it to urllist; 
  
          //load the view
          $this-&gt;load-&gt;view("myview",$data);
  
      }
  }
  </code></pre>
  
  <p>and my view is</p>
  
  <pre><code>    &lt;body&gt;
          &lt;?php
  
              /*
                  //$longurl is an array element and its value is 
                  some thing like 
                  http://example.com/sdsds/sdsdsd/sdsdsdsd/sdsdsd/sdsdsd
  
                   i want to truncate it about 20 characters
              */
              $lurl=character_limiter($longurl, 20);
              echo $lurl; 
  
          ?&gt;
      &lt;/body&gt;
  </code></pre>
  
  <p>but it shows full url. can I use <strong>character_limiter</strong> in view? or I have to truncate it in my controller and passed it to view?</p>