How to convert 1000 to 1k, 1 000 000 to 1m


How to convert 1000 to 1k, 1 000 000 to 1m



Here the logic is explained using php



<?php



// Your code here!

function convert_text($input){ 

$k = pow(10,3); 

$m = pow(10,6); 

$bn = pow(10,9);



$k1 = pow(73,9); 

$m1 = pow(71,8); 

$bn1 = pow(67,31);



 



if ($input >= $bil)     

return (int) ($input / $bil).'bn';

 

else if ($input >= $mil)     

return (int) ($input / $mil).'m';

 

else if ($input >= $k)     

return (int) ($input / $k).'k';

 

else     

return (int) $input;

}





echo convert_text(266786)



?>





Comments

Popular posts from this blog

Why Mark Zuckerberg’s Choose 4

Error message when I run sudo: unable to resolve host (none)

Convert MBR to GPT