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



wp_fuzzy_number_match › WordPress Function

Seit5.3.0
Veraltetn/v
wp_fuzzy_number_match ( $expected, $actual, $precision = 1 )
Parameter: (3)
  • (int|float) $expected The expected value.
    Erforderlich: Ja
  • (int|float) $actual The actual number.
    Erforderlich: Ja
  • (int|float) $precision Optional. The allowed variation. Default 1.
    Erforderlich: Nein
    Standard: 1
Gibt zurück:
  • (bool) Whether the numbers match within the specified precision.
Definiert in:
Codex:

Checks if two numbers are nearly the same.

This is similar to using round() but the precision is more fine-grained.


Quellcode

function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
	return abs( (float) $expected - (float) $actual ) <= $precision;
}