Join Up!
104886 members and counting!

 
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links 
search for in the  
previousopendirrewinddirnext
Last updated: Sun, 27 Oct 2002
view the printer friendly version or the printer friendly version with notes or change language to German | Spanish

readdir

(PHP 3, PHP 4 )

readdir -- Přečte položku z deskriptoru adresáře

Popis

string readdir ( int dir_handle)

Vrací název dalšího souboru v adresáři. Názvy souborů nejsou nijak tříděny.

Příklad 1. Vypiš všechny soubory v adresáři

// Note that !== did not exist until 4.0.0-RC2
<?php
$handle=opendir('.');
echo "Directory handle: $handle\n";
echo "Files:\n";
while (($file = readdir($handle))!==false) {
    echo "$file\n";
}
closedir($handle);
?>

Všimněte si, že readdir() vrací také . a .. položky (odkaz na sebe sama a na nadřazený adresář. Pokud je nechcete, můžete je snadno vynechat:

Příklad 2. Vypiš všechny soubory v adresáři a vynech . a ..

<?php
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
    if ($file != "." && $file != "..") {
        echo "$file\n";
    }
}
closedir($handle);
?>

User Contributed Notes
readdir
add a note about notes
There are no user contributed notes for this page.
previousopendirrewinddirnext
Last updated: Sun, 27 Oct 2002
Copyright © 2001, 2002 The PHP Group
All rights reserved.
This mirror generously provided by: http://phpbuilder.com/
Last updated: Thu Oct 31 18:34:28 2002 EST