PHP Format Numbers to Nearest Thousands

PHP Format Numbers to Nearest Thousands

Here comes a function to to nearest thousands such as Kilos, Millions, Billions, and Trillions with comma.



 thousandsCurrencyFormat(3000); // 3k
 thousandsCurrencyFormat(35500); // 35.5k
 thousandsCurrencyFormat(905000); // 905k
 thousandsCurrencyFormat(5500000); // 5.5m
 thousandsCurrencyFormat(88800000); // 88.8m
 thousandsCurrencyFormat(745000000); // 745m
 thousandsCurrencyFormat(2000000000); // 2b
 thousandsCurrencyFormat(22200000000); // 22.2b
 thousandsCurrencyFormat(1000000000000); // 1t (1 trillion)

This content needs to be improved, please leave a reply :) Here

Related posts