It can be tricky to really understand the value of 7312946 or 983217 at the first glance. Saying 7.3M and 983k seems like a much better option. How to convert numbers into a nicer format? Like this:
/**
* create a nicely formatted number
* @param $number a large number
* @param $shorten default true = append k or M, false = format with commas and dots
* @return int
*/
function createHumanReadableInteger($number, $shorten = true) {
if (is_numeric($number)) {
if ($shorten) {
if ($number < 100000) {
$return_int = number_format($number, 0);
} else {
$number_proc = $number;
$units = explode(" ", "B k M G T P");
for ($i = 0; $number_proc > 1000; $i++) {
$number_proc = $number_proc / 1000;
}
if ($number > 1000000) {
$return_int = round($number_proc, 2) . " " . $units[$i];
} else {
$return_int = round($number_proc, 1) . " " . $units[$i];
}
}
} else {
$return_int = number_format($number, 0);
}
return $return_int;
} else {
return 0;
}
}