lewis987 Posted July 15, 2007 Share Posted July 15, 2007 basically to functions to get the free size left on the hard-drive and another to get the total space on it. code below. $dir = $server1['data']; $size = disk_total_space($dir); function formatTotal($size){ switch (true){ case ($size > 1048576): $size /= 1048576; $suffix = 'MB'; break; case ($size > 1024): $size /= 1024; $suffix = 'KB'; break; default: $suffix = 'B'; } return round($size, 2).$suffix; } $goose = disk_free_space($dir); function zz($goose){ switch (true){ case ($size > 1048576): $size /= 1048576; $suffix = 'MB'; break; case ($size > 1024): $size /= 1024; $suffix = 'KB'; break; default: $suffix = 'B'; } return round($size, 2).$suffix; } if i echo $goose it shows the space in bytes but i want it to show it in MB or KB depending on the size. Im on PHP 4.4.9 (i believe). Basically its when i cann formatTotal it shows the total space (that one works fine) but when i call "zz" it just shows me "0B" and when i show $goose i get the proper size in bytes. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted July 15, 2007 Author Share Posted July 15, 2007 found my error! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.