Page MenuHomePhorge

function mfilter($list, $method, $negate)
libphutil Technical Documentation (Core Utilities)

Filter a list of objects by executing a method across all the objects and filter out the ones with empty() results. this function works just like ifilter(), except that it operates on a list of objects instead of a list of arrays.

For example, to remove all objects with no children from a list, where 'hasChildren' is a method name, do this:

mfilter($list, 'hasChildren');

The optional third parameter allows you to negate the operation and filter out nonempty objects. To remove all objects that DO have children, do this:

mfilter($list, 'hasChildren', true);
Parameters
array$listList of objects to filter.
string$methodA method name.
bool$negateOptionally, pass true to drop objects which pass the filter instead of keeping them.
Return
arrayList of objects which pass the filter.