-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.php
66 lines (45 loc) · 1.73 KB
/
example.php
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FileSystemFinder Example</title>
</head>
<body>
<pre>
<?php
include_once 'FileSystemFinder.php';
// List files using static method FileSystemFinder::find()
$filelist = FileSystemFinder::find('C:/php/ext/php_pdo_*.dll');
print_r($filelist); // via __debugInfo()
echo "\r\n";
// List files using file() method with a wildcard pattern
$filelist = (new FileSystemFinder('C:/php/ext'))
->file('php_pdo_*.dll');
print_r($filelist->toArray()); // using toArray()
echo "\r\n";
// List files using dir() and file() method with wildcard and regex patterns
$filelist = (new FileSystemFinder('C:/php'))
->dir('dev|ext') // using default wildcard matcher
->file('/[0-9]/', FileSystemFinder::REGEX_MATCHER); // using the specified regex matcher
foreach ($filelist as $path) { // via SeekableIterator interface
echo "$path\r\n";
}
echo "\r\n";
// A combination of using both static and non-static method
$filelist = FileSystemFinder::find('C:/php/dev|ext', FileSystemFinder::DIR_ONLY);
print_r($filelist);
$filelist = $filelist->file('/[0-9]/', FileSystemFinder::REGEX_MATCHER);
print_r($filelist);
echo "\r\n";
// List files using wfio extension
if (extension_loaded('wfio')) {
$filelist = FileSystemFinder::find('wfio://E:/Music/* 笑话/* 欢乐剧场/??? *大*.wma');
for ($i = 0; $i < count($filelist); $i++) { // via Countable interface
echo "[$i] => $filelist[$i]\r\n"; // via ArrayAccess interface
}
} else {
echo "The wfio extension is not loaded.\r\n";
}
?>
</pre>
</body>
</html>