rest_validate_array_contains_unique_items()
Checks if an array is made up of unique items.
Хуков нет.
Возвращает
true|false
. True if the array contains unique items, false otherwise.
Использование
rest_validate_array_contains_unique_items( $input_array );
- $input_array(массив) (обязательный)
- The array to check.
Список изменений
С версии 5.5.0 | Введена. |
Код rest_validate_array_contains_unique_items() rest validate array contains unique items WP 6.7.1
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; }