php Convert Bytes To KB, MB, GB
Con
function formatBytes($bytes) {
	if ($bytes > 0) {
		
		$i = floor(log($bytes) / log(1024));
		$sizes = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
		return sprintf('%.02F', round($bytes / pow(1024, $i),1)) * 1 . ' ' . @$sizes[$i];
	
	} else {
		return 0;
	}
}
echo formatBytes(1500000);
1.4 MB
19 Related pages
- About PHP
 - php Convert Bytes To KB, MB, GB
 - PHP date and time
 - php define path to dir
 - PHP display all images from a folder
 - PHP get image as function
 - php image upload
 - php image width and height
 - PHP list all files in directory and subdirectories
 - PHP list all image with info
 - php list files as array
 - php list files with similar name regardless of file extension
 - php search for file by name without file extension
 - PHP send and catch data
 - php strip tags
 - php url full path
 - php, list all file and folder from dir without file extension
 - PHP, SQL, insert from HTML input
 - WordPress page conditions front page
 























