I think I have this right, but I would like someone to confirm this.
function storageAmmount()
{
system('stat /web/'.$user."/ | grep Size: > /web/".$user."/log/storage");
$storage = fopen('/web/'.$user.'/log/storage');
$storage = str_replace('Size:', " ", $storage);
$storage = preg_replace('Blocks:(((A-Z), a-z), 1-9)','',$storage);
}
This is the line in the text file:
Size: 4096 Blocks: 8 IO Block: 4096 directory
I try to get only a numerical value: "Size:", the word "Size" and everything else is useless to me.
I mostly look at preg_replace. Is it just me or regular, a little confusing? Any suggestions. Thanks for any help in advance.
Hooray!
Phill
Good,
Here's what the function looks like now:
function storageAmmount()
{
$storage = filesize('/web/'.$user.'/');
$final = $storage/(1024*1024*1024);
return $final;
}
Wherever I put number_format (), I'm not sure if it will go in the equation or in the return statement. I got it in both cases when it returns "0.00".
V1.
function storageAmmount()
{
$storage = filesize('/web/'.$user.'/');
$final = number_format($storage/(1024*1024*1024), 2);
return $final;
}
or v2.
function storageAmmount()
{
$storage = filesize('/web/'.$user.'/');
$final = $storage/(1024*1024*1024);
return number_format($final, 2);
}
do not work, and both of them return "0.00". Any thoughts?