17Jan/110
array_walk() in CodeIgniter
Recently I needed to call trim() for multiple variables in an array in my CodeIgniter application, but had issues with calling the custom function using array_walk() to do so. A bit of Googling and experimentation led me to this answer:
function stuff()
{
// trim array data
array_walk($data, array($this, 'trim_value'));
$this->load->view('preview_view', $data);
}
function trim_value(&$value)
{
$value = trim($value);
}
You have to pass array_walk() or array_walk_recursive() an array with $this as a defined variable/pointer.
Try that piece of code if you're having an issue!
