WordPress at a glance
function is not described

rest_validate_array_contains_unique_items() WP 5.5.0

Checks if an array is made up of unique items.

No Hooks.

Return

true|false. True if the array contains unique items, false otherwise.

Usage

rest_validate_array_contains_unique_items( $array );
$array(array) (required)
The array to check.

Changelog

Since 5.5.0 Introduced.

Code of rest_validate_array_contains_unique_items() WP 5.7.2

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