Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 1409

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>readdir</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Directory functions"
HREF="ref.dir.html"><LINK
REL="PREVIOUS"
TITLE="opendir"
HREF="function.opendir.html"><LINK
REL="NEXT"
TITLE="rewinddir"
HREF="function.rewinddir.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>PHP Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="function.opendir.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.rewinddir.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.readdir"
>readdir</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN7766"
></A
>readdir -- read entry from directory handle</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN7769"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><P
></P
><CODE
CLASS="FUNCDEF"
>string readdir</CODE
>(int dir_handle);<P
></P
></DIV
><P
>&#13;     Returns the filename of the next file from the directory. The
     filenames are not returned in any particular order.
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 1. List all files in the current directory</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php
  3&nbsp;$handle=opendir('.');
  4&nbsp;echo "Directory handle: $handle\n";
  5&nbsp;echo "Files:\n";
  6&nbsp;while ($file = readdir($handle)) {
  7&nbsp;    echo "$file\n";
  8&nbsp;}
  9&nbsp;closedir($handle); 
 10&nbsp;?&#62;
 11&nbsp;      </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     Note that <B
CLASS="function"
>readdir()</B
> will return the . and
     .. entries.  If you don't want these, simply strip them out:
     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 2. 
       List all files in the current directory and strip out . and
       ..
      </B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php 
  3&nbsp;$handle=opendir('.'); 
  4&nbsp;while ($file = readdir($handle)) { 
  5&nbsp;    if ($file != "." &#38;&#38; $file != "..") { 
  6&nbsp;        echo "$file\n"; 
  7&nbsp;    } 
  8&nbsp;}
  9&nbsp;closedir($handle); 
 10&nbsp;?&#62;
 11&nbsp;      </PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.opendir.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.rewinddir.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>opendir</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.dir.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>rewinddir</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>