This has boggled me for a while. I am running through a directory and echo'ing out its contents, and I want to exclude the ".." and "." files.
Now, this code works:
if ($files = scandir("temp/"))
{
foreach ($files as $file)
{
if ($file == ".." OR $file == ".")
{
}
else {
echo $file;
echo "
";
}
}
}
But this doesn't...
if ($files = scandir("temp/"))
{
foreach ($files as $file)
{
if ($file != ".." OR $file != ".")
{
echo $file;
echo "
";
}
}
}
For obvious reasons the second lump of code is more what I want, because I really hate having the true statement do nothing.
No comments:
Post a Comment