Created
September 8, 2018 04:10
-
-
Save ogaty/13c9307325a30d44808ae16b8d97f07c to your computer and use it in GitHub Desktop.
特定ディレクトリ配下をrecursiveで探索 php directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = 'node_modules'; | |
function getFileList($dir) { | |
$iterator = new RecursiveDirectoryIterator($dir); | |
$iterator = new RecursiveIteratorIterator($iterator); | |
$list = array(); | |
foreach ($iterator as $fileinfo) { // $fileinfoはSplFiIeInfoオブジェクト | |
if ($fileinfo->isFile() && preg_match('/\.js$/', $fileinfo->getPathname())) { | |
$list[] = $fileinfo->getPathname(); | |
} | |
} | |
return $list; | |
} | |
var_dump(getFileList($path)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment