Number
in package
This class provides functions for working with numbers.
It includes formatting numbers, performing divisions, and formatting numbers with date placeholders.
Tags
Table of Contents
- division() : mixed
- Perform division.
- format() : string
- Format a number with comma as thousands separator (supports decimal values).
- printf() : string
- Format a number with placeholders for date values (year, month, day).
Methods
division()
Perform division.
public
static division( $dividend, $divisor) : mixed
If the divisor is equal to 0, return 0.
Parameters
Tags
Return values
mixed —The result of the division
format()
Format a number with comma as thousands separator (supports decimal values).
public
static format(float $value[, string $thousands_sep = ',' ]) : string
If there are no decimal places, return an integer value. No rounding is performed.
Parameters
- $value : float
-
The number to be formatted
- $thousands_sep : string = ','
-
(optional) Thousands separator (default ',')
Tags
Return values
string —The formatted number
printf()
Format a number with placeholders for date values (year, month, day).
public
static printf(string $format, mixed $value[, string $prefix = '' ]) : string
Parameters
- $format : string
-
The format string
- $value : mixed
-
The number to be formatted
- $prefix : string = ''
-
(optional) A prefix to be added to the format string
Tags
Return values
string —The formatted number with date placeholders