PHP code example of madbyad / mpl-number-converter
1. Go to this page and download the library: Download madbyad/mpl-number-converter library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
madbyad / mpl-number-converter example snippets
echo NumberConverter::numberToAbbreviate(1250000);
"1.3 M"
echo NumberConverter::numberToAbbreviate(1250000, [
10**3 => "RB",
10**6 => "JT",
10**9 => "M",
10**12 => "T",
]);
"1.3 JT"
echo NumberConverter::numberToAbbreviate("1.3 M");
1300000
echo NumberConverter::numberToAbbreviate("1.3 JT", [
10**3 => "RB",
10**6 => "JT",
10**9 => "M",
10**12 => "T",
]);
1300000
echo NumberConverter::numberToFormat(15000000);
echo NumberConverter::numberToFormat(15000000, "-");
echo NumberConverter::numberToFormat(15000000, "_");
echo NumberConverter::numberToFormat(15000000, " ");
"15.000.000"
"15-000-000"
"15_000_000"
"15 000 000"
echo NumberConverter::formatToNumber("15.000.000");
echo NumberConverter::formatToNumber("15-000-000");
echo NumberConverter::formatToNumber("15_000_000");
echo NumberConverter::formatToNumber("15 000 000");
15000000
15000000
15000000
15000000
echo NumberConverter::numberToAlphabet(1);
echo NumberConverter::numberToAlphabet(2);
echo NumberConverter::numberToAlphabet(3);
echo "\n";
echo NumberConverter::numberToAlphabet(4, false);
echo NumberConverter::numberToAlphabet(5, false);
echo NumberConverter::numberToAlphabet(6, false);
"A"
"B"
"C"
"d"
"e"
"f"
echo NumberConverter::alphabetToNumber("A");
echo NumberConverter::alphabetToNumber("O");
echo NumberConverter::alphabetToNumber("Z");
1
13
26
echo NumberConverter::numberToBinary(2);
echo NumberConverter::numberToBinary(18);
echo NumberConverter::numberToBinary(64);
"10"
"10010"
"1000000"
echo NumberConverter::binaryToNumber("10");
echo NumberConverter::binaryToNumber("10010");
echo NumberConverter::binaryToNumber("1000000");
2
18
64
echo NumberConverter::numberToHexadecimal(10);
echo NumberConverter::numberToHexadecimal(159);
echo NumberConverter::numberToHexadecimal(1200);
echo "\n";
echo NumberConverter::numberToHexadecimal(10, false);
echo NumberConverter::numberToHexadecimal(159, false);
echo NumberConverter::numberToHexadecimal(1200, false);
"A"
"9F"
"4B0"
"a"
"9f"
"4b0"
echo NumberConverter::hexadecimalToNumber("A");
echo NumberConverter::hexadecimalToNumber("9F");
echo NumberConverter::hexadecimalToNumber("4B0");
10
159
1200
echo NumberConverter::numberToOctal(16);
echo NumberConverter::numberToOctal(64);
echo NumberConverter::numberToOctal(511);
"20"
"100"
"777"
echo NumberConverter::numberToOctal("20");
echo NumberConverter::numberToOctal("100");
echo NumberConverter::numberToOctal("777");
16
64
511
echo NumberConverter::numberToRoman(1);
echo NumberConverter::numberToRoman(2);
echo NumberConverter::numberToRoman(3);
echo NumberConverter::numberToRoman(4);
echo NumberConverter::numberToRoman(5);
echo NumberConverter::numberToRoman(6);
echo NumberConverter::numberToRoman(7);
echo NumberConverter::numberToRoman(8);
echo NumberConverter::numberToRoman(9);
echo NumberConverter::numberToRoman(10);
"I"
"II"
"III"
"IV"
"V"
"VI"
"VII"
"VIII"
"IX"
"X"
echo NumberConverter::romanToNumber("I");
echo NumberConverter::romanToNumber("II");
echo NumberConverter::romanToNumber("III");
echo NumberConverter::romanToNumber("IV");
echo NumberConverter::romanToNumber("V");
echo NumberConverter::romanToNumber("VI");
echo NumberConverter::romanToNumber("VII");
echo NumberConverter::romanToNumber("VIII");
echo NumberConverter::romanToNumber("IX");
echo NumberConverter::romanToNumber("X");
1
2
3
4
5
6
7
8
9
10