<HTML ><HEAD ><TITLE >glob</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="Funciones del sistema de ficheros" HREF="ref.filesystem.html"><LINK REL="PREVIOUS" TITLE="fwrite" HREF="function.fwrite.html"><LINK REL="NEXT" TITLE="is_dir" HREF="function.is-dir.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.fwrite.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.is-dir.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.glob" ></A >glob</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN19849" ></A ><P > (PHP 4 >= 4.3.0)</P >glob -- Find pathnames matching a pattern</DIV ><DIV CLASS="refsect1" ><A NAME="AEN19852" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >glob</B > ( string pattern [, int flags])<BR ></BR ><P > The <B CLASS="function" >glob()</B > function searches for all the pathnames matching <TT CLASS="parameter" ><I >pattern</I ></TT > according to the rules used by the shell. No tilde expansion or parameter substitution is done. </P ><P > Returns an array containing the matched files/directories or <TT CLASS="constant" ><B >FALSE</B ></TT > on error. </P ><P > Valid flags: <P ></P ><UL ><LI ><P > <TT CLASS="constant" ><B >GLOB_MARK</B ></TT > - Adds a slash to each item returned </P ></LI ><LI ><P > <TT CLASS="constant" ><B >GLOB_NOSORT</B ></TT > - Return files as they appear in the directory (no sorting) </P ></LI ><LI ><P > <TT CLASS="constant" ><B >GLOB_NOCHECK</B ></TT > - Return the search pattern if no files matching it were found </P ></LI ><LI ><P > <TT CLASS="constant" ><B >GLOB_NOESCAPE</B ></TT > - Backslashes do not quote metacharacters </P ></LI ><LI ><P > <TT CLASS="constant" ><B >GLOB_BRACE</B ></TT > - Expands {a,b,c} to match 'a', 'b', or 'c' </P ></LI ><LI ><P > <TT CLASS="constant" ><B >GLOB_ONLYDIR</B ></TT > - Return only directory entries which match the pattern </P ></LI ></UL > </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN19889" ></A ><P ><B >Ejemplo 1. Convenient way how <B CLASS="function" >glob()</B > can replace <A HREF="function.opendir.html" ><B CLASS="function" >opendir()</B ></A > and friends. </B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php foreach (glob("*.txt") as $filename) { echo "$filename size " . filesize($filename) . "\n"; } /* Output will look something like: funclist.txt size 44686 funcsummary.txt size 267625 quickref.txt size 137820 */ ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > See also <A HREF="function.opendir.html" ><B CLASS="function" >opendir()</B ></A >, <A HREF="function.readdir.html" ><B CLASS="function" >readdir()</B ></A > and <A HREF="function.closedir.html" ><B CLASS="function" >closedir()</B ></A >, <A HREF="function.fnmatch.html" ><B CLASS="function" >fnmatch()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.fwrite.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.is-dir.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >fwrite</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.filesystem.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >is_dir</TD ></TR ></TABLE ></DIV ></BODY ></HTML >