Page 1 of 1

PHP Number Conversions

Posted: Wed Oct 18, 2006 12:20 pm
by amir
I am looking to have a script that can convert numbers like 1,123,000,567 to something like 1.23B. I will need this script to cover

K=thousands,
M=Millions,
B=Billions,
T=Trillions,
Q=quadrillions,
U=quintillion
S=sextillion

Posted: Wed Oct 18, 2006 12:29 pm
by feyd
Well, your blocks would indicate that it won't be a native number, so a simple floor((strlen($foo) + 3) / 4) will tell you which notch it falls in, then a substr() can perform the last bit.