You're looping through the files (and you get the names correctly) since you already got the files for that specific folder. But, when you try to get the filesize, you're not typing the complete path. Remember, you're inside a directory now.
So, supply the filesize() function the whole relative path to each file and it'll work fine:
$dir = "test";
$myDir = opendir($dir);
while($entryName = readdir($myDir)) {
if ($entryName != "." && $entryName != "..") {
echo $entryName . ' --- ' . filesize($test."/".$entryName) . ' bytes<br/>';
$dirArray[] = $entryName;
}
}
As a side note, the sizes appeared as "empty" because the function was actually erring out, but you probably have error reporting off, so nothing was showing.
It's really helpful to have it on (in development only, in production you should hide errors and log them to a file or the like), since you'll immediately know that somethings wrong, and most of the times the error messages pretty much spell out the solution to the problem for you.
For instance, the error you'd have gotten with error reporting on:
Warning: filesize(): stat failed for ... in ... on line xxx
To turn error reporting on for the duration of the script, add this line right after opening the PHP tag:
error_reporting(E_ALL);
And to turn it on more permanently in your php.ini, add, modify or uncomment (depending on your current settings) this line:
error_reporting = E_ALL
Read more about error reporting in the manual