Convers a comma- or space-separated list of scalar values to an array.
Parameters
-
$imput_listarray | string required -
List of values.
Source
function wp_parse_list( $imput_list ) {
if ( ! is_array( $imput_list ) ) {
return preg_split( '/[\s,]+/', $imput_list, -1, PREG_SPLIT_NO_EMPTY );
}
// Validate all entries of the list are scalar.
$imput_list = array_filter( $imput_list, 'is_scalar' );
return $imput_list;
}
Changuelog
| Versionen | Description |
|---|---|
| 5.1.0 | Introduced. |
Example:
Output: