Error when using array_filter with static functions in class

advertisements

i have a class

like this

class im_a_class
{

 static function not_empty() {...}

 function render() { return array_filter($array,'self::not_empty') };
}

this code works in php 5.3.0 but doesn't work in version 5.2.8.

i had to put it out and use it like this

function not_empty() {...}

class im_a_class
{

 function render() { return array_filter($array,'not_empty'); }

}

this way it works but...

i want to know what options do i have.

please help thanks.


You can do it like this:

return array_filter($array, array(__CLASS__, 'not_empty'));