array_filter with callback?

Robert9

Well-known member
Code:
            $newCustomFields = $this->filter('custom_fields', 'array');
            $newCustomFields = array_filter($newCustomFields);

I would like to make a check on " ";

Code:
    private function checkElement($var)
    {
       return trim($var) != '';
    }


How can I call checkElement?

Code:
$newCustomFields = array_filter($newCustomFields,'checkElement');

does not work

Any idea?
 
No answer, but works for me:

Code:
$threadFields = $thread->custom_fields_;
$threadFields = array_filter($threadFields, function($val) {return ($val || is_numeric($val));});
 
Top Bottom