samedi 3 octobre 2015

Dynamic PHP If statement for filtering results

I am currently building a class for directory/file handeling for a project im working on. to make it more flexable I would like to find a way to make a dynamic if statement to handle exclusions. I can see it being helpfull else where as well. I would like to make it so IF($file !=.... were some thing like

PUBLIC $filter = '$file != "."....';

IF($filter)

So that I could set $filter in the main program just before calling FileLib1\GetDirectory() currently I have the following inside of GetDirectory()

        while ($file = readdir($handler)) 
        {

  // if file isn't this directory or its parent, add it to the results
        //If $file !=  statement excludes things we dont want in the listing.  
        if ($file != "." && $file != ".." && $file !="0grp" && $file !="0ren" && $file != "unz.sh" && $file != "index.php" && $file != "galery.php" && $file != "forward.jpeg" && $file != "helper.html" && $file != "image.php" && $file != "reverse.jpeg") 
    {
        $results[] = $file;
        }

        }

Aucun commentaire:

Enregistrer un commentaire