How do I use a class method as a callback function?

billiecamel

New Member
If I use \[code\]array_walk\[/code\] inside a class function to call another function of the same class\[code\]class user{ public function getUserFields($userIdsArray,$fieldsArray) { if((isNonEmptyArray($userIdsArray)) && (isNonEmptyArray($fieldsArray))) { array_walk($fieldsArray, 'test_print'); } } private function test_print($item, $key) { //replace the $item if it matches something }}\[/code\]It gives me the following error - \[code\]Warning: array_walk() [function.array-walk]: Unable to call test_print() - function does not exist in ...\[/code\]So, how do I specify \[code\]$this->test_print()\[/code\] while using array_walk() ?Thanks,
Sandeepan
 
Back
Top