Replace the class name with the object:
return array_filter($array1, array($this, "odd"));
After posting the below comments I took a walk around the lake and it occurred to me that if array_filter was smart enough to deal with a class name then it might be smart enough to deal with an object as well.
The above change works on your sample. But you trying to do something a bit dangerous. And if the odd() method tries to make changes to the object then you may get unexpected results.
So if you still have trouble then the following should work:
You are using asdf_odd as a static function.
There is no $this defined within static functions because there is no actual object created. Hence the error.
To do what I think you are trying to do will require writing a wrapper function for array_filter to call.
$asdf_odd_filter_object = null; /* Just a holder for now */
function asdf_odd_filter($var)
{
global $asdf_odd_filter_object;
return $asdf_odd_filter_object->odd($var);
}
class asdf()
{
function testthis()
{
global $asdf_odd_filter_object;
$array1 = array(6,7,8,9,10,11,12);
$asdf_odd_filter_object = $this;
return array_filter($array1, 'asdf_odd_filter');
}
Remember that the array_filter function has no idea it is trying to call an object's method.
Untested code.