File size calculator

File size calculator function return file size format into kb, mb or gb.

function file_size($size, $out = 'kb', $precision = 2)
{
    switch ($out) {
        case 'kb':
            return round($size / 1024, $precision);
            break;
        case 'mb':
            return round($size / (1024 * 1024), $precision);
            break;
        case 'gb':
            return round($size / (1024 * 1024 * 1024), $precision);
            break;
    }
    return false;
}

Tags

No tag here.

Recommended pages

Random string generator...

Random string generator. Optionally, you can give it a desired string length. function rnd_string($len = 24) { $str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $str...

Change timestamp to custom format...

Use this function for change timestamp to custom format......

SQL escape string function...

Escapes special characters in a string for use in an SQL statement. howewer it check get_magic_quotes_gpc function is enable or no. if true , it strips string from slashes and escaped string from spec...

Better parse_str in php...

parse_str() is fine for simple stuff but it's not the same as PHP's built way of creating the $_GET magic variable. Why?!?......