Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

how to transfer MB into GB php code example

Example: convert byte to megabyte php

function formatBytes($bytes, $precision = 2) { 
    $units = array('B', 'KB', 'MB', 'GB', 'TB'); 

    $bytes = max($bytes, 0); 
    $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); 
    $pow = min($pow, count($units) - 1); 

    // Uncomment one of the following alternatives
    // $bytes /= pow(1024, $pow);
    // $bytes /= (1 << (10 * $pow)); 

    return round($bytes, $precision) . ' ' . $units[$pow]; 
}

Tags:

Php Example

Related

javascripts date object code example untracked files are committed by default code example how to do disable on a select input code example see ip cmd code example mongoose auto time stamp code example np concatenate axis=1 code example exibir texto completo sem reticencias em html code example error: src refspec develop does not match any error: failed to push some refs to 'origin' code example how to check the version of laptop code example c# list get last 500 alues code example ver particiones montadas linux code example run python script and regain terminal code example

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy