wp_list_filter

Filters a list of objects, based on a set of key => value arguments.

Description

(array) wp_list_filter( (array) $list, (array) $args = array(), (string) $operator = 'AND' ); 

Returns (array)

Array of found values.

Parameters (3)

0. $list (array)
An array of objects to filter.
1. $args — Optional. (array) => array()
An array of key => value arguments to match against each object. Default empty array.
2. $operator — Optional. (string) => 'AND'
The logical operation to perform. AND means all elements from the array must match. OR. means only one element needs to match. NOT means no elements may match. Default AND .

Usage

  1. if ( !function_exists( 'wp_list_filter' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // An array of objects to filter. 
  5. $list = array(); 
  6.  
  7. // Optional. An array of key => value arguments to match 
  8. // against each object. Default empty array. 
  9. $args = array(); 
  10. $operator = 'AND'; 
  11.  
  12. // NOTICE! Understand what this does before running. 
  13. $result = wp_list_filter($list, $args, $operator); 
  14.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { 
  2. if ( ! is_array( $list ) ) { 
  3. return array(); 
  4.  
  5. $util = new WP_List_Util( $list ); 
  6. return $util->filter( $args, $operator );