3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function abreviateTotalCount($value) { $abbreviations = array(12 => 'T', 9 => 'B', 6 => 'M', 3 => 'K', 0 => ''); foreach($abbreviations as $exponent => $abbreviation) { if($value >= pow(10, $exponent)) { return round(floatval($value / pow(10, $exponent)),1).$abbreviation; } } } echo abreviateTotalCount(10034);
Output for 4.3.0 - 7.1.0
10K