user8406207
user8406207

Reputation:

How to get all files in that folder

Hello i have folder with some files inside and i want to create script inside in that folder.

Upvotes: 0

Views: 49

Answers (2)

akond
akond

Reputation: 16035

You could use SPL for that:

$filesystem_iterator = new FilesystemIterator(".", FilesystemIterator::SKIP_DOTS + FilesystemIterator::CURRENT_AS_PATHNAME);
$filesystem_iterator = new RegexIterator($filesystem_iterator, "~backup_\\d{4}_\\d{2}_\\d{2}.zip~");
foreach ($filesystem_iterator as $pathname)
{
    var_dump ($pathname);
    ...
}

Upvotes: 1

Ramy Talal
Ramy Talal

Reputation: 91

PHP has a function named glob() which let's you find directories and files with a pattern: http://php.net/manual/en/function.glob.php

Upvotes: 1

Related Questions