Quick Search:
 
 PHP Code: Nicely Format File Size Jump to:  
Category: >> PHP Code >> Nicely Format File Size  

<< lastnext >>

Snippet Name: Nicely Format File Size

Description: Nicely format the size of a given file properly.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

<?PHP 
 
FUNCTION get_filesize ($dsize) { 
            IF (STRLEN($dsize) <= 9 && STRLEN($dsize) >= 7) {                  
                $dsize = NUMBER_FORMAT($dsize / 1048576,1); 
                RETURN "$dsize MB"; 
            } ELSEIF (STRLEN($dsize) >= 10) { 
                $dsize = NUMBER_FORMAT($dsize / 1073741824,1); 
                RETURN "$dsize GB"; 
            } ELSE { 
                $dsize = NUMBER_FORMAT($dsize / 1024,1); 
                RETURN "$dsize KB"; 
            } 
} 
?>
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org