Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



rest_are_values_equal ›

Seit5.7.0
Veraltetn/v
rest_are_values_equal ( $value1, $value2 )
Parameter: (2)
  • (mixed) $value1 The first value to check.
    Erforderlich: Ja
  • (mixed) $value2 The second value to check.
    Erforderlich: Ja
Gibt zurück:
  • (bool) True if the values are equal or false otherwise.
Definiert in:
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.


Quellcode

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

	return $value1 === $value2;
}