Currency
in package
Convert numbers to currency format (Baht, Dollar)
Tags
Table of Contents
- bahtEng() : string
- Convert number to text (English)
- bahtThai() : string
- Convert number to text (Thai Baht)
- calcVat() : float
- Calculate the VAT amount based on the given amount and VAT rate.
- format() : string
- Format a number with specified decimal digits and thousands separator.
- engFormat() : string
- Format a number into its English word representation.
Methods
bahtEng()
Convert number to text (English)
public
static bahtEng(string $thb) : string
Parameters
- $thb : string
Tags
Return values
string —bahtThai()
Convert number to text (Thai Baht)
public
static bahtThai(string $thb) : string
Parameters
- $thb : string
Tags
Return values
string —calcVat()
Calculate the VAT amount based on the given amount and VAT rate.
public
static calcVat(float $amount, float $vat[, bool $vat_ex = true ]) : float
Parameters
- $amount : float
-
The amount to calculate VAT for.
- $vat : float
-
The VAT rate.
- $vat_ex : bool = true
-
Indicates whether the amount is VAT-exclusive (true) or VAT-inclusive (false).
Tags
Return values
float —The VAT amount.
format()
Format a number with specified decimal digits and thousands separator.
public
static format(float $amount[, int $digit = 2 ][, string $thousands_sep = ',' ][, bool $round = true ]) : string
Parameters
- $amount : float
-
The number to format.
- $digit : int = 2
-
The number of decimal digits to include. Default is 2.
- $thousands_sep : string = ','
-
The character used as a thousands separator. Default is ','.
- $round : bool = true
-
Whether to round the number or not. Default is true.
Tags
Return values
string —The formatted number as a string.
engFormat()
Format a number into its English word representation.
private
static engFormat(int $number) : string
Parameters
- $number : int
-
The number to format.
Return values
string —The English word representation of the number.