File: lib-misc.inc.php

package info (click to toggle)
php-doc 20140201-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 74,084 kB
  • ctags: 4,040
  • sloc: xml: 998,137; php: 20,812; cpp: 500; sh: 177; makefile: 63; awk: 28
file content (25 lines) | stat: -rw-r--r-- 453 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
function list_files($basedir, $extensions = array('xml')) {
	
	if (!is_dir($basedir)) {
		return false;
	}
	
	$files = array();
	foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basedir)) as $file) {
		
		if (!$file->isFile()) {
			continue;
		}

		$filepath = $file->getPathname();
		
		if (!in_array(pathinfo($filepath, PATHINFO_EXTENSION), $extensions)) {
			continue;
		}
		
		$files[] = $filepath;
	}
	return $files;
}