What do you mean a NUMBER i thought it was a number
Your function is returning this:
return number_format($size/$tb,2)." TB";
So, for example, that could be
"4.3 TB"
And that's a string, not a number.
That's why when you do this:
$size += dirsize($fullfilename);
The string will end up as
"3.4 B2.4 KB300 B"
and etc...
So, instead of
return number_format(etc);
you should just
return $size;
And THEN, outside the function, you have the if statements with the number format.
Diego