Uses
Uses | Description |
---|---|
wp-includes/rest-api.php: rest_stabilize_value() | Stabilizes a value following JSON Schema semantics. |
Checks if an array is made up of unique items.
(array) (Required) The array to check.
(bool) True if the array contains unique items, false otherwise.
File: wp-includes/rest-api.php
function rest_validate_array_contains_unique_items( $array ) { $seen = array(); foreach ( $array as $item ) { $stabilized = rest_stabilize_value( $item ); $key = serialize( $stabilized ); if ( ! isset( $seen[ $key ] ) ) { $seen[ $key ] = true; continue; } return false; } return true; }
Version | Description |
---|---|
5.5.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_validate_array_contains_unique_items