Phalcon Filters

Hi,

I am trying to get the value through Phalcon resultset filter.

$result = $params['resultset']->filter(function($object) {
    if ($object->$params['key'] == $params['value'] ) { 
        print $params['key']; 
        return $object; 
    }
});

Can you suggest me how do I pass the $params inside the filter function. Am I doing correct ?

Raja K



84.5k
edited Apr '15

This way:

$result = $params['resultset']->filter(function($object) use ($params) {
    if ($object->$params['key'] == $params['value'] ) { 
        print $params['key']; 
        return $object; 
    }
});