mirror of
https://github.com/hotspotbilling/phpnuxbill.git
synced 2025-08-15 23:38:01 +02:00
Text::convertDataUnit($datalimit, $unit)
This commit is contained in:
parent
bf71393fff
commit
da3ef535a2
2 changed files with 16 additions and 0 deletions
|
@ -67,4 +67,20 @@ class Text
|
||||||
{
|
{
|
||||||
return preg_match("/<[^<]+>/", $string, $m) != 0;
|
return preg_match("/<[^<]+>/", $string, $m) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function convertDataUnit($datalimit, $unit = 'MB')
|
||||||
|
{
|
||||||
|
$unit = strtoupper($unit);
|
||||||
|
if ($unit == 'KB') {
|
||||||
|
return $datalimit * 1024;
|
||||||
|
} elseif ($unit == 'MB') {
|
||||||
|
return $datalimit * 1024 * 1000;
|
||||||
|
} elseif ($unit == 'GB') {
|
||||||
|
return $datalimit * 1024 * 1000 * 1000;
|
||||||
|
} elseif ($unit == 'TB') {
|
||||||
|
return $datalimit * 1024 * 1000 * 1000 * 1000;
|
||||||
|
} else {
|
||||||
|
return $datalimit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue