php - how to count together the size of files when they are created in foreach loop -
i using folder in user can upload files. these files outputted name , size.
$dir = "users/$username"; $files = scandir($dir); foreach ($files $file) { if ($file != '.' && $file != '..') { echo sizeformat(filesize($dir . '/' . $file)); }
so output looks this:
koala.jpg => 600kb
jellyfish.jpg => 600kb
tulips.jpg => 500kb
how can count sizes together?
something like: toal size files: 1700kb
like this:
$dir = "users/$username"; $files = scandir($dir); $total = 0; foreach ($files $file) { if ($file != '.' && $file != '..') { $total += filesize($dir . '/' . $file); echo sizeformat(filesize($dir . '/' . $file)); } } echo $total;
Comments
Post a Comment