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