37 lines
795 B
PHP
37 lines
795 B
PHP
<?php
|
|
function decade($zahl)
|
|
{
|
|
if (! is_numeric($zahl) || $zahl == 0)
|
|
return $zahl;
|
|
$si = array(
|
|
- 4 => 'p',
|
|
- 3 => 'n',
|
|
- 2 => 'μ',
|
|
- 1 => 'm',
|
|
0 => '',
|
|
1 => 'K',
|
|
2 => 'M',
|
|
3 => 'G',
|
|
4 => 'T'
|
|
);
|
|
|
|
$e = 0;
|
|
|
|
if ($zahl < 1) {
|
|
while ($zahl < 1 || $zahl >= 1000) {
|
|
$zahl = $zahl * 1000;
|
|
$e --;
|
|
}
|
|
} else {
|
|
while ($zahl < 1 || $zahl >= 1000) {
|
|
$zahl = $zahl / 1000;
|
|
$e ++;
|
|
}
|
|
}
|
|
return $zahl . ' ' . $si[$e];
|
|
}
|
|
|
|
function onlyNumeric($num) {
|
|
return preg_replace("/[^0-9\.\-]+/", "", $num);
|
|
}
|
|
?>
|