Quantcast
Viewing latest article 2
Browse Latest Browse All 3

Answer by FMK for php file_get_contents loop all files in same directory

I wrote a function similar to your needs not long ago:

private function getFilesByPattern($pattern = '*.html', $flags = 0){    $files = glob($pattern, $flags);    foreach (glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {        $files = array_merge($files, $this->getTestFiles($dir . '/' . basename($pattern), $flags));    }    return $files;}

This function also searches recusively through sub directories! For $flags look into the flags of glob: http://php.net/manual/de/function.glob.php

Can be called like this: getTestFiles('../src/directory/*.html')


Viewing latest article 2
Browse Latest Browse All 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>