wp_parse_list() WordPress Function

The wp_parse_list() function is used to parse a string into an array. This function is useful for creating lists of data from a string. The wp_parse_list() function is located in the wp-includes/functions.php file.

wp_parse_list( array|string $list ) #

Converts a comma- or space-separated list of scalar values to an array.


Parameters

$list

(array|string)(Required)List of values.


Top ↑

Return

(array) Array of values.


Top ↑

Source

File: wp-includes/functions.php

function wp_parse_list( $list ) {
	if ( ! is_array( $list ) ) {
		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
	}

	return $list;
}


Top ↑

Changelog

Changelog
VersionDescription
5.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More