rest_sanitize_array( mixed $maybe_array )

Converts an array-like value to an array.


Parameters

$maybe_array

(Required) The value being evaluated.


Return

(array) Returns the array extracted from the value.


Source

File: wp-includes/rest-api.php

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 );
}

Changelog

Changelog
Version Description
5.5.0 Introduced.