$sanitizer->float() method

Sanitize to floating point value

Usage

// basic usage
$float = $sanitizer->float($value);

// usage with all arguments
$float = $sanitizer->float($value, array $options = []);

Arguments

NameType(s)Description
valuefloat, string, int
options (optional)array

Optionally specify one or more options in an associative array:

  • precision (int|null): Optional number of digits to round to (default=null)
  • mode (int): Mode to use for rounding precision (default=PHP_ROUND_HALF_UP);
  • blankValue (null|int|string|float): Value to return (whether float or non-float) if provided $value is an empty non-float (default=0.0)
  • min (float|null): Minimum allowed value, excluding blankValue (default=null)
  • max (float|null): Maximum allowed value, excluding blankValue (default=null)

Return value

float


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.161

Twitter updates

  • ProcessWire 3.0.162 continues improvements to selector operators, fixes various minor issues, adds new API convenience methods, improves documentation, optimizes and refactors various portions of code and DB queries, and more— More
    10 July 2020
  • New dedicated page in our online documentation for Selector Operators: More
    10 July 2020
  • New ProcessWire query expansion search operators can now add automatic word inflections and lemmatisation, enabling you to build even smarter search engines with ProcessWire. More
    3 July 2020

Latest news

  • ProcessWire Weekly #322
    In the 322nd issue of ProcessWire Weekly we're going to focus on the latest core updates, take a closer look at the newly released Wire Text Tools (EN) module, and introduce a brand new site of the week. Read on!
    Weekly.pw / 11 July 2020
  • Powerful new text-searching abilities in 3.0.160
    In ProcessWire 3.0.160 we’ve got some major upgrades and additions to our text-search abilities. This brings a whole new level of power to $pages->find() and similar API calls, especially when it comes to search engine type queries.
    Blog / 19 June 2020
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer