언젠가 써먹을 수 있을 것 같아서 정리해둡니다 :)
function getMemberSrlsWithSignature($dir, &$results = array()) { $sub_dir = scandir($dir); foreach ( $sub_dir as $key => $val ) { $path = realpath($dir . DIRECTORY_SEPARATOR . $val); if ( !is_dir($path) ) { preg_match('/(\d+)\.signature\.php/', $path, $matches); $results[] = $matches[1]; } else if ( $val !== '.' && $val !== '..' ) { getMemberSrlsWithSignature($path, $results); } } return $results; } $dir = RX_BASEDIR . 'files/member_extra_info/signature'; $member_list_with_signature = getMemberSrlsWithSignature($dir);
원출처 : https://stackoverflow.com/questions/24783862/list-all-the-files-and-folders-in-a-directory-with-php-recursive-function#answer-24784144