Jump to: navigation, search

Php readdir

From w3cyberlearnings

Contents

PHP function readdir

This function returns the current directory entry opened by opendir().

Syntax readdir

dh is a current directory handle

readdir(dh);

Note

Returns a list of file name on success or FALSE on failure.

Example 1

<?php 
  $path = dirname(__FILE__).'/mydir';
  $dh = opendir($path);
  while(($d = readdir($dh)) !== false) {
     echo "name: $d : type: ". filetype($pfile)."\n";
  }
  closedir($dh);
?>

Output

name: learn.txt : type: 
name: a1 : type: 
name: ac : type: 
name: a2 : type: 
name: . : type: 
name: ab : type: 
name: .. : type: 

--chdir-- chroot-- closedir-- dir-- getcwd-- opendir-- readdir-- rewinddir-- scandir--

Navigation
Web
SQL
MISC
References