04-09-2009, 09:37 AM
|
#10 (permalink)
|
|
The Wanderer
Join Date: Jan 2008
Posts: 13
Thanks: 0
|
I have a few comments on your code.
PHP Code:
while ($file = readdir($handler)) {
because readdir returns a bool, you can check if readdir succeeds or not
PHP Code:
while (false !== ($file = readdir($handler))) {
And this line isn't really usefull, cause you make the if statement but don't do anything with it.
PHP Code:
if ($file != '.' && $file != '..')
Change it to something like this
PHP Code:
if(in_array($sFile, array('.', '..')) === true) {
continue; //skip the file
} else {
// Do something
And the final thing is this.
PHP Code:
array_push($files,$file);
According to php.net array_push it is better to use $array[] = $val if you add only one element to array
Quote:
|
Note: If you use array_push() to add one element to the array it's better to use $array[] = because in that way there is no overhead of calling a function.
|
|
|
|
|