$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.137

Twitter updates

  • New post: This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140— More
    6 September 2019
  • We added WebP image support this year and many have been adopting it in existing projects. We look at a process used for migrating existing websites to WebP images— from preliminary considerations to implementation & testing, w/lots of tips & tricks too: More
    16 August 2019
  • Core version 3.0.137 on the dev branch adds the ability to hook multiple methods at once, in a single call. This post details how it works and provides a useful example of how you might put it to use in your development environment— More
    2 August 2019

Latest news

  • ProcessWire Weekly #279
    This week in the 279th issue of ProcessWire Weekly we're going to introduce some of the latest third party modules out there, and highlight a brand new site of the week. Read on!
    Weekly.pw / 14 September 2019
  • ProcessWire 3.0.140 and FormBuilder v40
    This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140.
    Blog / 6 September 2019
  • Subscribe to weekly ProcessWire news

“The end client and designer love the ease at which they can update the website. Training beyond how to log in wasn’t even necessary since ProcessWire’s default interface is straightforward.” —Jonathan Lahijani