Join Up!
104879 members and counting!

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

readdir

(PHP 3, PHP 4 )

readdir -- lee las entradas del manejador de directorios

Descripcion

string readdir ( int dir_handle)

Devuelve el nombre del siguiente fichero en el directorio. Los nombres de ficheros no son devueltos en ningun orden especial .

Ejemplo 1. Listar todos los ficheros en un directorio

<?php
      $handle=opendir('.');
      echo "Directory handle: $handle\n";
      echo "Files:\n";
      while ($file = readdir($handle)) {
       echo "$file\n";
       }
       closedir($handle); 
       ?>

Tener en cuenta que readdir() devolvera tambien . y .. Si no quereis estas entradas podeis borrarlas:

Ejemplo 2. Listar todos los ficheros en un directorio excepto . y ..

<?php 
      $handle=opendir('.'); 
      while ($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: Tue, 29 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