Created
May 18, 2014 03:25
-
-
Save averj/648eb30c1285981b4f36 to your computer and use it in GitHub Desktop.
round.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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