Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function prettify_num($num){
- $text = array(
- 1 => 'thousand',
- 2 => 'million',
- 3 => 'billion',
- 4 => 'trillion'
- );
- $exp = 3 * floor( ( strlen( (string) $num ) - 1 ) / 3);
- $rounded_num = round($num / pow(10,$exp), 1);
- if(($rounded_num / 100) > 1) $rounded_num = round($rounded_num);
- return $rounded_num .' '. $text[$exp / 3];
- }
Add Comment
Please, Sign In to add comment