wpseek.com
Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



rest_validate_array_contains_unique_items › WordPress Function

Od5.5.0
Przestarzałyn/a
rest_validate_array_contains_unique_items ( $input_array )
Parametry:
  • (array) $input_array The array to check.
    Wymagane: Tak
Powrót:
  • (bool) True if the array contains unique items, false otherwise.
Zdefiniowane na:
Codex:

Checks if an array is made up of unique items.



Źródło

function rest_validate_array_contains_unique_items( $input_array ) {
	$seen = array();

	foreach ( $input_array as $item ) {
		$stabilized = rest_stabilize_value( $item );
		$key        = serialize( $stabilized );

		if ( ! isset( $seen[ $key ] ) ) {
			$seen[ $key ] = true;

			continue;
		}

		return false;
	}

	return true;
}