WordPress at a glance

wp_parse_slug_list() WP 1.0

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

Works based on: sanitize_title()
✈ 1 time = 0.000199s = fast | 50000 times = 3.64s = fast PHP 7.0.8, WP 4.7

No Hooks.

Return

Array. Sanitized array of slugs.

Usage

wp_parse_slug_list( $list );
$list(array/string) (required)
List of slugs.

Code of wp_parse_slug_list: wp-includes/functions.php VER 4.9.8

<?php
function wp_parse_slug_list( $list ) {
	if ( ! is_array( $list ) ) {
		$list = preg_split( '/[\s,]+/', $list );
	}

	foreach ( $list as $key => $value ) {
		$list[ $key ] = sanitize_title( $value );
	}

	return array_unique( $list );
}

Related Functions

From tag: array list help functions (sorting arrays objects)

More from tag: sanitize_

More from category: Helper Functions

No comments
    Hello, !     Log In . Register