Menu

## Number
in package

Number.php : 19

This class provides functions for working with numbers.

It includes formatting numbers, performing divisions, and formatting numbers with date placeholders.

##### Tags

see
  https://www.kotchasan.com/

### 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()

Number.php : 54

Perform division.

`public static division( $dividend, $divisor) : mixed`

If the divisor is equal to 0, return 0.

##### Parameters

$dividend :

  The dividend

$divisor :

  The divisor

##### Tags

assert

  (1, 2) [==] 0.5

assert

  (1, 0) [==] 0

##### Return values

mixed —

The result of the division

#### format()

Number.php : 36

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

assert

  (100) [==] "100"

assert

  (100.1) [==] "100.1"

assert

  (1000.12) [==] "1,000.12"

assert

  (1000.1555) [==] "1,000.1555"

##### Return values

string —

The formatted number

#### printf()

Number.php : 75

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

assert

  ('G%04d', 1) [==] "G0001"

assert

  ('G-%s-%04d', 1, 'PREFIX') [==] "G-PREFIX-0001"

example

  G-%Y-%M-%D-%04d G-64-08-09-0001

example

  G-%y-%m-%d-%04d G-21-8-9-0001

example

  G-%YY-%M-%D-%04d G-2564-08-09-0001

example

  G-%yy-%m-%d-%04d G-2021-8-9-0001

##### Return values

string —

The formatted number with date placeholders

## Search results