|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
myhan Smarty n00b
Joined: 26 Sep 2003 Posts: 3
|
Posted: Fri Sep 26, 2003 1:31 am Post subject: smarty_modifier_size_format |
|
|
Format size like file size
[php:1:e90e24f7a4]
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: size_format
* Purpose: format size
* Author: srni@wiscom.com.cn
*
* -------------------------------------------------------------
*/
function smarty_modifier_size_format($string, $sizestring=array("B", "K", "M"))
{
$bytes = (int)$string;
$type = $sizestring[0];
if ($bytes > 1024) {
$bytes /= 1024;
$type = $sizestring[1];
}
if ($bytes / 1024 > 1) {
$bytes /= 1024;
$type = $sizestring[2];
}
if ($bytes < 100) {
$bytes *= 100;
settype($bytes, 'integer');
$bytes /= 100;
} else {
settype($bytes, 'integer');
}
return $bytes . " " . $type;
}
/* vim: set expandtab: */
?>[/php:1:e90e24f7a4] |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|