wp_parse_id_list

Clean up an array, comma- or space-separated list of IDs.

Description

(array) wp_parse_id_list( (array|string) $list ); 

Returns (array)

Sanitized array of IDs.

Parameters (1)

0. $list (array|string)
List of ids.

Usage

  1. if ( !function_exists( 'wp_parse_id_list' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // List of ids. 
  5. $list = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_parse_id_list($list); 
  9.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_parse_id_list( $list ) { 
  2. if ( !is_array($list) ) 
  3. $list = preg_split('/[\s, ]+/', $list); 
  4.  
  5. return array_unique(array_map('absint', $list));