reinit
This commit is contained in:
37
numbers.php
Normal file
37
numbers.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user