File tree Expand file tree Collapse file tree 1 file changed +33
-6
lines changed
reference/filesystem/functions Expand file tree Collapse file tree 1 file changed +33
-6
lines changed Original file line number Diff line number Diff line change 19
19
the libc glob() function, which is similar to the rules used by common
20
20
shells.
21
21
</para >
22
+ <simpara >
23
+ The behavior on Unix systems and macOS is determined by the system's
24
+ implementation of glob(). On Windows, an implementation that conforms
25
+ to the POSIX 1003.2 definition for glob() is used, and it includes
26
+ an extension to handle the <literal >[!...]</literal > convention for
27
+ negating a range.
28
+ </simpara >
22
29
</refsect1 >
23
30
24
31
<refsect1 role =" parameters" >
78
85
<para >
79
86
Returns an array containing the matched files/directories, an empty array
80
87
if no file matched or &false; on error.
88
+ Unless <literal >GLOB_NOSORT</literal > was used, the names will
89
+ be sorted alphanumerically.
81
90
</para >
82
- <note >
83
- <para >
84
- On some systems it is impossible to distinguish between empty match and an
85
- error.
86
- </para >
87
- </note >
88
91
</refsect1 >
89
92
90
93
<refsect1 role =" examples" >
@@ -110,6 +113,30 @@ foreach (glob("*.txt") as $filename) {
110
113
funclist.txt size 44686
111
114
funcsummary.txt size 267625
112
115
quickref.txt size 137820
116
+ ]]>
117
+ </screen >
118
+ </example >
119
+ <example >
120
+ <title >
121
+ Example with a more complex pattern
122
+ </title >
123
+ <programlisting role =" php" >
124
+ <![CDATA[
125
+ <?php
126
+ foreach (glob("path/*/*.{txt,md}", \GLOB_BRACE) as $filename) {
127
+ echo "$filename\n";
128
+ }
129
+ ?>
130
+ ]]>
131
+ </programlisting >
132
+ &example.outputs.similar;
133
+ <screen >
134
+ <![CDATA[
135
+ path/docs/mailinglist-rules.md
136
+ path/docs/README.md
137
+ path/docs/release-process.md
138
+ path/pear/install-pear.txt
139
+ path/Zend/README.md
113
140
]]>
114
141
</screen >
115
142
</example >
You can’t perform that action at this time.
0 commit comments