Title: wp_parse_list
Published: February 22, 2019
Last modified: February 24, 2026

---

# wp_parse_list( array|string $input_list ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#wp--skip-link--target)

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#parameters)󠁿

 `$input_list`array|stringrequired

List of values.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#return)󠁿

 array Array of values.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#source)󠁿

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

    	// Validate all entries of the list are scalar.
    	$input_list = array_filter( $input_list, 'is_scalar' );

    	return $input_list;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/functions.php#L4974)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/functions.php#L4974-L4983)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Theme::get_block_patterns()](https://developer.wordpress.org/reference/classes/wp_theme/get_block_patterns/)`wp-includes/class-wp-theme.php` |

Gets block pattern data for a specified theme.

  | 
| [WP_REST_Pattern_Directory_Controller::get_transient_key()](https://developer.wordpress.org/reference/classes/wp_rest_pattern_directory_controller/get_transient_key/)`wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php` |

Include a hash of the query args, so that different requests are stored in separate caches.

  | 
| [WP_REST_Menu_Items_Controller::get_item_schema()](https://developer.wordpress.org/reference/classes/wp_rest_menu_items_controller/get_item_schema/)`wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php` |

Retrieves the nav menu item’s schema, conforming to JSON Schema.

  | 
| [rest_sanitize_array()](https://developer.wordpress.org/reference/functions/rest_sanitize_array/)`wp-includes/rest-api.php` |

Converts an array-like value to an array.

  | 
| [rest_is_array()](https://developer.wordpress.org/reference/functions/rest_is_array/)`wp-includes/rest-api.php` |

Determines if a given value is array-like.

  | 
| [rest_parse_embed_param()](https://developer.wordpress.org/reference/functions/rest_parse_embed_param/)`wp-includes/rest-api.php` |

Parses the “_embed” parameter into the list of resources to embed.

  | 
| [WP_REST_Controller::get_fields_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_controller/get_fields_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-controller.php` |

Gets an array of fields to be included on the response.

  | 
| [rest_filter_response_fields()](https://developer.wordpress.org/reference/functions/rest_filter_response_fields/)`wp-includes/rest-api.php` |

Filters the REST API response to include only an allow-listed set of response object fields.

  | 
| [wp_parse_slug_list()](https://developer.wordpress.org/reference/functions/wp_parse_slug_list/)`wp-includes/functions.php` |

Cleans up an array, comma- or space-separated list of slugs.

  | 
| [WP_REST_Server::get_index()](https://developer.wordpress.org/reference/classes/wp_rest_server/get_index/)`wp-includes/rest-api/class-wp-rest-server.php` |

Retrieves the site index.

  | 
| [WP_Comment_Query::get_comment_ids()](https://developer.wordpress.org/reference/classes/wp_comment_query/get_comment_ids/)`wp-includes/class-wp-comment-query.php` |

Used internally to get a list of comment IDs matching the query vars.

  | 
| [wp_parse_id_list()](https://developer.wordpress.org/reference/functions/wp_parse_id_list/)`wp-includes/functions.php` |

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

  | 
| [get_pages()](https://developer.wordpress.org/reference/functions/get_pages/)`wp-includes/post.php` |

Retrieves an array of pages (or hierarchical post type items).

  |

[Show 8 more](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.1.0](https://developer.wordpress.org/reference/since/5.1.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/wp_parse_list/?output_format=md#comment-content-7163)
 2.   [rabmalin](https://profiles.wordpress.org/rabmalin/)  [  2 years ago  ](https://developer.wordpress.org/reference/functions/wp_parse_list/#comment-7163)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_parse_list%2F%23comment-7163)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_parse_list%2F%23comment-7163)
 4. Example:
 5.     ```php
        $string = 'apple, banana, cherry';
        $items = wp_parse_list( $string );
        print_r( $items );
        ```
    
 6. Output:
 7.     ```php
        Array
        (
            [0] => apple
            [1] => banana
            [2] => cherry
        )
        ```
    
 8.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_parse_list%2F%3Freplytocom%3D7163%23feedback-editor-7163)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_parse_list%2F)
before being able to contribute a note or feedback.