factoring2117 Posted May 24, 2009 Share Posted May 24, 2009 Hi, I don't know if this is simple or not, but I need a script that would convert a number like this 1230000 to 1.23M or 1.23B for 1230000000. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/159458-converting-numbers-to-123m-for-1230000/ Share on other sites More sharing options...
jackpf Posted May 24, 2009 Share Posted May 24, 2009 <?php $i = 10000000; $i = (string)$i; if(strlen($i) >= 6 && strlen($i) <= { echo substr($i, 0, strlen($i) - 6).'million'; } ?> You mean like that? Quote Link to comment https://forums.phpfreaks.com/topic/159458-converting-numbers-to-123m-for-1230000/#findComment-841139 Share on other sites More sharing options...
papaface Posted May 24, 2009 Share Posted May 24, 2009 <?php echo round((1230000/1000000),2).' million'; echo "<br />"; echo round((1000000000/1000000000),2).' billion'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/159458-converting-numbers-to-123m-for-1230000/#findComment-841142 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.