0

I'm trying to find the best method of selecting .exe files within a directory, ignoring files inside other directories.

So far, I have the following:

$files = scandir('/path/to/dir');

Now, how can I remove "..", "." and other directories and files within that directory that are not .exe files?

Thanks.

Fede E.
  • 2,118
  • 4
  • 23
  • 39
  • 3
    Possible duplicate of [PHP list of specific files in a directory](http://stackoverflow.com/questions/3062154/php-list-of-specific-files-in-a-directory) – chris85 Jan 16 '17 at 15:32
  • By iterating through the entries and filtering them, obviously. Or you simply use the ``glob()`` function. – arkascha Jan 16 '17 at 15:32
  • @arkascha mind helping me there? I saw the glob() function, but wasn't able to understand exactly how it works. – Fede E. Jan 16 '17 at 15:37
  • The documentation of the `glob()` functions comes with easy examples, I do not really see what might be difficult to follow there. Would you mind asking in a more specific way so that we can offer specific help? – arkascha Jan 16 '17 at 15:38
  • The linked thread has `glob` examples, http://stackoverflow.com/a/3062165/4333555 (the accepted answer isn't always the best one). – chris85 Jan 16 '17 at 15:40
  • @chris85 AWESOME. Thanks. found the solution there. Thanks again. – Fede E. Jan 16 '17 at 15:41

1 Answers1

0
$files = glob('path/to/dir/*.exe');

Thanks @chris85

Fede E.
  • 2,118
  • 4
  • 23
  • 39