Zend_Measure_Binary will already do the heavy lifting for you. http://framework.zend.com/manual/en/zend.measure.types.html#zend.measure.types.binary
On Wed, Feb 4, 2009 at 5:45 PM, Michał Zieliński <zie...@gmail.com> wrote: > > Sometimes you`d like to present the file size in a more friendlier way than > 1000000000000B. > Is not that it is hard to write such view helper or filter to do so but I > see that Zend_Validator_Size already do something like this. > > protected function _toByteString($size) > { > $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); > for ($i=0; $size >= 1024 && $i < 9; $i++) { > $size /= 1024; > } > return round($size, 2) . $sizes[$i]; > } > > I`d like to ask if this method shouldn`t be outside? As a filter or helper? > If you`d like to show filesize on your website you hardly ever want to > display it without formatting. Now you have to copy the above code or write > similar on your own. > What do you think? > -- > View this message in context: > http://www.nabble.com/New-filter--tp21843007p21843007.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- A.J. Brown web | http://ajbrown.org phone | (937) 660-3969