title: How to use callback function in codeigniter
body: <p>I have a array <strong>$services</strong> and this array contains below values :  </p>
  
  <pre><code>Array
  (
    [0] =&gt; One way
    [1] =&gt;  Hourly
    [2] =&gt;  To Airport
    [3] =&gt;  From Airport
    [4] =&gt;   Birthday
    [5] =&gt;  Wedding
    [6] =&gt;  Concert
    [7] =&gt;   Sporting Event
    [8] =&gt;   Cruise Party
    [9] =&gt;  Funeral
  )
  </code></pre>
  
  <p>You can notice that some of values in array contain space.<br>
  To remove this space from array values I created a array_walk function which walk into array and trim the white space.</p>
  
  <pre><code>public function trim_value(&amp;$value) {
       $value = trim($value);
  }  
  </code></pre>
  
  <p>As you all know that the syntax of array_walk function is :</p>
  
  <pre><code>array_walk($array, 'callback_function');
  </code></pre>
  
  <p>Now I want to use this function in codeigniter controller. As I know that a function in controller is being used as $this->function in another function.<br>
  So I tried to use callback function as : </p>
  
  <pre><code>array_walk($services, $this-&gt;trim_value);
  </code></pre>
  
  <p>It always throws an below error :</p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
  
  <pre><code>&lt;p&gt;Severity: Notice&lt;/p&gt;
  &lt;p&gt;Message:  Undefined property: Attribute::$trim_value&lt;/p&gt;
  &lt;p&gt;Filename: controllers/attribute.php&lt;/p&gt;
  &lt;p&gt;Line Number: 230&lt;/p&gt;
  </code></pre>
  </blockquote>
  
  <p>So can somebody tell me that how to use callback function in one of controller's function ?</p>