Strange Foreach Problem
Posted: Tue Apr 25, 2006 2:47 pm
Seeing unexpected results with the following code.
var_dump shows 2 files in the directory, plus "." and "..", but the foreach isn't iterating the last element.
Ouput:
Code: Select all
// READ ALL FILES FROM DIRECTORY
$directory = scandir($filepath);
var_dump($directory);
foreach ($directory as $file)
{
echo $file . "\n";
}Ouput:
Code: Select all
***** VAR DUMP *****
array(4) {
[0]=>
string(1) "."
[1]=>
string(2) ".."
[2]=>
string(14) "core.class.php"
[3]=>
string(18) "registry.class.php"
}
***** FOREACH *****
.
..
core.class.php