wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_fuzzy_number_match › WordPress Function

Since5.3.0
已弃用n/a
wp_fuzzy_number_match ( $expected, $actual, $precision = 1 )
参数: (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
    默认: 1
返回:
  • (bool) Whether the numbers match within the specified precision.
定义在:
文档:

Checks if two numbers are nearly the same.

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


源码

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