Return to Snippet

Revision: 33382
at October 8, 2010 07:48 by vagrantradio


Initial Code
$dir = ".";

if( is_dir( $dir ) ){
	if( $dir_handle = opendir( $dir ) ){
		while( $filename = readdir( $dir_handle ) ){
			echo "filename: {$filename}<br />" ;
		}
		//rewinddir($dir_handle) to start over
		closedir( $dir_handle );
	}
}

echo "<hr />";

if( is_dir( $dir ) ){
	$dir_array = scandir( $dir );
	foreach( $dir_array as $file ){
		if( stripos( $file, '.' ) > 0){
			echo "filename: {$file}<br />";
		}
	}
}

Initial URL


Initial Description
Prints out the contents of a directory.

Initial Title
List items in directory

Initial Tags
php

Initial Language
PHP