I am having an issue with array_filter recognizing my callback function. It works on my local machine but not on my development and was hoping someone could point me in the right direction as to why. This is how I was using it :
private function some_function()
{
$arr = array('value','value','value');
$arr = array_filter($arr,'ClassName::filter_function');
}
public filter_function($element)
{
//do stuff and return
}
This worked fine on my local machine but when I uploaded it to a test server I get the message "Warning
array_filter(): The second argument, 'ClassName::filter_function', should be a valid callback in path/to/file.
I have tried to change it to
$arr = array_filter($arr,array($this,'filter_function'));
as well as
$arr = array_filter($arr,array('ClassName','filter_function'));
But to now avail. The last two my local machine didn't like either. The machines ARE running different versions of PHP, my local is 5.3.1 and the hosted is 5.2.14 however I haven't read anything that suggests this should be an issue in this case.
Could anyone suggest another way I could make this work or have an idea what could be going wrong? Any help is appreciated. Thanks much!
Edit : And after all that I realize I am a moron who forgot up the last change I made to the server from local.
array_filter($arr,array($this,'function_name'));
Does indeed work as it should. All is well and I am embarrassed. Thanks
This post has been edited by Jstall: 22 February 2011 - 03:05 PM

New Topic/Question
Reply




MultiQuote




|