rest_sanitize_array

函数


rest_sanitize_array ( $maybe_array )
参数
  • (mixed)
    $maybe_array
    The value being evaluated.
    Required:
返回值
  • (array) Returns the array extracted from the value.
定义位置
  • wp-includes/rest-api.php
    , line 1514
引入
5.5.0
弃用

将一个类似数组的值转换为数组。

function rest_sanitize_array( $maybe_array ) {
	if ( is_scalar( $maybe_array ) ) {
		return wp_parse_list( $maybe_array );
	}

	if ( ! is_array( $maybe_array ) ) {
		return array();
	}

	// Normalize to numeric array so nothing unexpected is in the keys.
	return array_values( $maybe_array );
}