A WordPress-centric search engine for devs and theme authors



wp_fuzzy_number_match ›

Since5.3.0
Deprecatedn/a
wp_fuzzy_number_match ( $expected, $actual, $precision = 1 )
Parameters: (3)
  • (int|float) $expected The expected value.
    Required: Yes
  • (int|float) $actual The actual number.
    Required: Yes
  • (int|float) $precision The allowed variation.
    Required: No
    Default: 1
Returns:
  • (bool) Whether the numbers match whithin the specified precision.
Defined at:
Codex:

Check if two numbers are nearly the same.

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



Source

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