Jump to content

bytes to megabytes


Vivid Lust

Recommended Posts

function sort_bytes($bytes)  //send down a vairable that contains the number of bytes.
{ 
	$size = $bytes / 1024; 
	if($size < 1024) 
	{ 
		$size = number_format($size, 2); 
		$size .= ' <i>KB</i>'; 
	}  
	else  
    { 
    	if($size / 1024 < 1024)  
    	{ 
    	    $size = number_format($size / 1024, 2); 
        	$size .= ' <i>MB</i>'; 
        }  
        else if ($size / 1024 / 1024 < 1024)   
        { 
        	$size = number_format($size / 1024 / 1024, 2); 
        	$size .= ' <i>GB</i>'; 
        }  
    } 
    return $size; 
}

 

that should do it for you :)

Link to comment
https://forums.phpfreaks.com/topic/115490-bytes-to-megabytes/#findComment-594156
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.