wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_fuzzy_number_match › WordPress Function

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 Optional. The allowed variation. Default 1.
    Required: No
    Default: 1
Returns:
  • (bool) Whether the numbers match within the specified precision.
Defined at:
Codex:

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