<?php
function reduz_numero($n) {
if ($n < 0) return "-" . reduz_numero(-$n);
$k = "";
while (round($n) >= 1000) { $k = $k . "k";
$n = $n / 1000;
}
}
echo " 5->" . reduz_numero( 5) . "\n";
echo " 999->" . reduz_numero( 999) . "\n";
echo " 1000->" . reduz_numero( 1000) . "\n";
echo " 1001->" . reduz_numero( 1001) . "\n";
echo " 1499->" . reduz_numero( 1499) . "\n";
echo " 1500->" . reduz_numero( 1500) . "\n";
echo " 1501->" . reduz_numero( 1501) . "\n";
echo " 10000->" . reduz_numero( 10000) . "\n";
echo " 999499->" . reduz_numero( 999499) . "\n";
echo " 999500->" . reduz_numero( 999500) . "\n";
echo " 999501->" . reduz_numero( 999501) . "\n";
echo "1000000000->" . reduz_numero(1000000000) . "\n";
echo " -77777->" . reduz_numero( -77777) . "\n";
echo " 9499999->" . reduz_numero( 9499999) . "\n";
echo " 9500000->" . reduz_numero( 9500000) . "\n";
?>