All pastes #255852 Raw Edit

Something

public text v1 · immutable
#255852 ·published 2006-11-23 13:11 UTC
rendered paste body
<?php
function dir2arr ( $path )
{
	$dirarr = array();

	if ( ! ($handle = opendir( $path )) )
		die("Couldn't open ".$path);
	
	chdir( './'.$path );
	
	while (false !== ($file = readdir($handle)))
	{
		if ( $file == '.' || $file == '..' ) continue;

		if ( is_dir( $file ) )
			$dirarr[$file] = dir2arr( $file );
		else
			$dirarr[] = $file;
	}

	closedir($handle);
	return $dirarr;
}

die( print_r( dir2arr('..'), true ) );
?>