rundiz / number
Number conversion (number to text) (Thai and English)
Installs: 20 804
Dependents: 0
Suggesters: 1
Security: 0
Stars: 1
Watchers: 2
Forks: 5
Open Issues: 0
Requires
- php: >=5.3.0
README
The Number classes provide formatting, convertions classes and methods for working with numeric values.
The Number[Language] class is for convert number to text in Thai and English languages.
In Thai language it is including number to Thai Baht conversion.
Example:
Convert number:
// For English require NumberEng.php, for Thai require NumberThai.php require 'Rundiz/Number/NumberEng.php'; // For English use NumberEng(), for Thai use NumberThai() $number_text = new Rundiz\Number\NumberEng(); echo $number_text->convertNumber('101'); // the result should be: // one hundred and one (for English) // หนึ่งร้อยเอ็ด (for Thai)
Convert Thai Baht:
require 'Rundiz/Number/NumberThai.php'; $number_text = new Rundiz\Number\NumberThai(); echo $number_text->convertBaht('3.23'); // the result should be: // สามบาทยี่สิบสามสตางค์
Convert file size to Bytes:
require 'Rundiz/Number/Number.php'; $number = new Rundiz\Number\Number(); echo $number->toBytes('1.3KB'); // 1300 echo $number->toBytes('1.3KiB'); // 1331.2
Convert to other file size unit from Bytes:
require 'Rundiz/Number/Number.php'; $number = new Rundiz\Number\Number(); echo $number->fromBytes('100000'); // 100.00 KB echo $number->fromBytes('133300'); // 133.30 KB echo $number->fromBytes('10000', 'KiB); // 9.76 KiB
Remove dot zero digits:
require 'Rundiz/Number/Number.php'; $Number = new Rundiz\Number\Number(); echo $Number->removeDotZero('1987.0000000000'); // 1987 echo $Number->removeDotZero('35.400'); // 35.400 echo $Number->removeDotZero('35.400', false); // 35.4 echo $Number->removeDotZero('35,400', false, ','); // 35,4 (european number format)
For more example, please look inside tests folder.