What im looking to do is format numbers in this way $3.0 T $838.3 B $838.3 M $1,000 $798 So that it trims it down to the whole number and decimal for trilling, billion, million etc.. I know if i played with it long enough I would figure it out, but my head is fried at the moment. I appreciate the help thank you.. TJ
If larger than 999999999 format as number / 1000000000 and add 'T' Else If larger than 999999 ... You get the idea. If, select case - there are a number of ways to do it.
You wouldnt be able to show an exact php if than \ else if \ else for applied application would you. I really hate to sound so lazy, just my mind is wrapping around it at the moment.. Its likely so easy im just not getting it..
function autoSize($amount) { if ($amount>1000000000000) return number_format($amount/1000000000000,1).' T'; if ($amount>1000000000) return number_format($amount/1000000000,1).' B'; if ($amount>1000000) return number_format($amount/1000000,1).' M'; return number_format($amount,0); } Code (markup):
Rukbat, you pretty much answered your own question! One way you can learn and teach yourself is, assuming you know fundamentals of PHP is to write what you require in plain english, and convert it using PHP syntax, trail and error, and debugging, and you'll be teaching and learning yourself