Logo
  • Home
  • About
  • Services
  • Blogs
  • Career
  • Contact
Logo

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

  • Address

    4th Floor, 4 Tabernacle Street London EC2A 4LU
  • Email

    info@podtech.com
  • Contact

    +44 (0) 20 8720 6583

Given a size in KB, try to return a more readable MB, GB or TB answer string

  • Home
  • Given a size in KB, try to return a more readable MB, GB or TB answer string
  • By podtech
  • In PHP

Given a size in KB, try to return a more readable MB, GB or TB answer string


function readable_size_for_kb($mykb)
{
        if ( $mykb > 1073741824 )
        {
                return sprintf("%5.1f TB",$mykb / 1024 / 1024/1024);
        }
        elseif ( $mykb > 1048576 )
        {
                return sprintf("%5.1f GB",$mykb / 1024 / 1024);
        }
        elseif ( $mykb > 1024 )
        {
                return sprintf("%5.1f MB",$mykb / 1024);
        }
        else
        {
                return sprintf("%5.1f KB",$mykb);
        }

}

GB or TB answer stringGiven a size in KBPHPtry to return a more readable MB
Readable Time – PHP, given a unix timestamp, return a readable time
RedHat vs Ubuntu – Useful Package Commands

Recent Posts

  • What is Software Piracy?
  • Microsoft and SITA Launch New Innovation Center in South Africa
  • Ericsson, Qualcomm and Thales to Launch 5G into Space
  • Schneider Electric Launches Free Data Center Professional Education Platform
  • UK and South Korea Reach Data Sharing Agreement

PodTech IO

The UK's #1 Software Development Company. PodTech IO builds custom software solutions for businesses. Call today for a free consultation

Company

  • About
  • Services
  • Contact
  • Blogs
  • Career

Terms

  • Terms & Conditions
  • Privacy Policy

Contact Us

  • ADDRESS

    Headquarter: Tabernacle Street London India: Vi john Tower, Gurgaon, Haryana
  • EMAIL

    info@podtech.com
  • CONTACT

    +44 (0) 20 8720 6583

Copyright ©2022 PodTech IO. All Rights Reserved

Logo