2002-05-18 14:08:25 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2002-11-13 23:36:37 +00:00
|
|
|
<!-- $Revision: 1.5 $ -->
|
2002-05-18 14:08:25 +00:00
|
|
|
<refentry id="function.glob">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>glob</refname>
|
|
|
|
<refpurpose>Find pathnames matching a pattern</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>array</type><methodname>glob</methodname>
|
|
|
|
<methodparam><type>string</type><parameter>pattern</parameter></methodparam>
|
|
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
The <function>glob</function> function searches for all the pathnames
|
|
|
|
matching <parameter>pattern</parameter> according to the rules used by
|
|
|
|
the shell. No tilde expansion or parameter substitution is done.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns an array containing the matched files/directories or &false; on
|
|
|
|
error.
|
|
|
|
</para>
|
2002-11-13 23:36:37 +00:00
|
|
|
<para> <!-- Added by john (john@php.net) //-->
|
|
|
|
Valid flags:
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_MARK - Adds a slash to each item returned</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_NOSORT - Return files as they appear in the directory (no sorting)</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_NOCHECK - Return the search pattern if no files matching it were found</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_NOESCAPE - Backslashes do not quote metacharacters</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_BRACE - Expands {a,b,c} to match 'a', 'b', or 'c' (PHP >= 4.3.0)</simpara>
|
|
|
|
</listitem>
|
|
|
|
<listitem>
|
|
|
|
<simpara>GLOB_ONLYDIR - Return only directory entries which match the pattern (PHP >= 4.3.0)</simpara>
|
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
2002-05-18 14:08:25 +00:00
|
|
|
<example>
|
|
|
|
<title>
|
|
|
|
Convenient way how <function>glob</function> can replace
|
|
|
|
<function>opendir</function> and friends.
|
|
|
|
</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
foreach (glob("*.txt") as $filename) {
|
|
|
|
echo "$filename size " . filesize($filename) . "\n";
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
This could result in the following output:
|
|
|
|
</para>
|
|
|
|
<screen>
|
|
|
|
funclist.txt size 44686
|
|
|
|
funcsummary.txt size 267625
|
|
|
|
quickref.txt size 137820
|
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
<para>
|
|
|
|
See also <function>opendir</function>,
|
|
|
|
<function>readdir</function> and
|
2002-11-13 23:36:37 +00:00
|
|
|
<function>closedir</function>, <function>fnmatch</function>.
|
2002-05-18 14:08:25 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|