// Byte Conversion Function conversion ($ size ){ $ Kb = 1024; // 1KB (Kibibyte, kilobytes) = 1024B, $ Mb = 1024 * $ kb; // 1 MB (Mebibyte, mb, or "MB") = 1024KB, $ Gb = 1024 * $ mb; // 1 GB (Gigabyte, Jilin byte, also known as "gigabit") = 1024 MB, $ Tb = 1024 * $ gb; // 1 TB (Terabyte, trillion bytes, too byte) = 1024 GB, $ Pb = 1024 * $ tb; // 1 pb (Petabyte, trillion bytes, byte) = 1024 TB, $ Fb = 1024 * $ pb; // 1EB (Exabyte, million bytes,) = pb, $ Zb = 1024 * $ fb; // 1ZB (Zettabyte, 100,000 billion bytes, Ze Bytes) = 1024EB, $ Yb = 1024 * $ zb; // 1YB (Yottabyte, 0.1 billion,) = 1024ZB, $ Bb = 1024 * $ yb; // 1BB (Brontobyte, 100 billion Bytes) = 1024YB If ($ size & lt; $ kb ){ Return $ size. "B "; } Else if ($ size & lt; $ mb ){ Return round ($ size/$ kb, 2). "KB "; } Else if ($ size & lt; $ gb ){ Return round ($ size/$ mb, 2). "MB "; } Else if ($ size & lt; $ tb ){ Return round ($ size/$ gb, 2). "GB "; } Else if ($ size & lt; $ pb ){ Return round ($ size/$ tb, 2). "TB "; } Else if ($ size & lt; $ fb ){ Return round ($ size/$ pb, 2). "PB "; } Else if ($ size & lt; $ zb ){ Return round ($ size/$ fb, 2). "EB "; } Else if ($ size & lt; $ yb ){ Return round ($ size/$ zb, 2). "ZB "; } Else { Return round ($ size/$ bb, 2). "YB "; } } |