Skip to content

Instantly share code, notes, and snippets.

@averj
Created May 18, 2014 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save averj/648eb30c1285981b4f36 to your computer and use it in GitHub Desktop.
Save averj/648eb30c1285981b4f36 to your computer and use it in GitHub Desktop.
round.php
<?php
function round($num) {
$conversions = array( // Add whatever conversion is needed
(float)1000000 => 'billion',
1000000 => 'million',
1000 => 'thousand'
);
foreach($conversions as $key => $val) {
if(($num / $key) >= 1) {
return round($num / $key, 1) . ' ' . $val;
}
}
}
echo amount(1000000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment