Using PHP, what’s an easy way to display file sizes with the appropriate denomination in regard to the amount of bytes?
Using PHP, what’s an easy way to display file sizes with the appropriate denomination
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I came up with a little function for this:
Works for me. Has a couple of nice options. You could extend it to encapsulate any range of sizes so long as it’s in descending order because that’s how the logic is set up here and it’s suitable. See http://www.webopedia.com/quick_ref/FileSizeConversionTable.asp for a decent list of file size denominations.