wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
rest_are_values_equal › WordPress Function
Depuis5.7.0
Dépréciéen/a
› rest_are_values_equal ( $value1, $value2 )
Paramètres: (2) |
|
Retourne: |
|
Défini(e) dans: |
|
Codex: |
Checks the equality of two values, following JSON Schema semantics.
Property order is ignored for objects. Values must have been previously sanitized/coerced to their native types.Fonctions en relation: rest_stabilize_value, rest_validate_enum, rest_sanitize_value_from_schema, rest_validate_value_from_schema, rest_parse_date
Source
function rest_are_values_equal( $value1, $value2 ) { if ( is_array( $value1 ) && is_array( $value2 ) ) { if ( count( $value1 ) !== count( $value2 ) ) { return false; } foreach ( $value1 as $index => $value ) { if ( ! array_key_exists( $index, $value2 ) || ! rest_are_values_equal( $value, $value2[ $index ] ) ) { return false; } } return true; } if ( is_int( $value1 ) && is_float( $value2 ) || is_float( $value1 ) && is_int( $value2 ) ) { return (float) $value1 === (float) $value2; } return $value1 === $value2; }