wp_parse_list

函式
wp_parse_list ( $list )
引數
  • (array|string) $list List of values.
    Required:
返回值
  • (array) Array of values.
定義位置
相關方法
wp_parse_id_listwp_parse_strwp_parse_slug_listwp_parse_urlwp_parse_args
引入
5.1.0
棄用
-

wp_parse_list: 這個函式解析一個以逗號分隔的列表並以陣列形式返回。它用於簡化對列表的處理。

將一個以逗號或空格分隔的標量值列表轉換為陣列。

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

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

	return $list;
}

常見問題

FAQs
檢視更多 >