Checks if two numbers are nearly the same.
Description
This is similar to using round() but the precision is more fine-grained.
Parameters
$expectedint|floatrequired- The expected value.
$actualint|floatrequired- The actual number.
$precisionint|floatoptional- The allowed variation.
Default:
1
Source
function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
return abs( (float) $expected - (float) $actual ) <= $precision;
}
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.