All pastes #256469 Raw Edit

Mine

public text v1 · immutable
#256469 ·published 2006-11-24 06:55 UTC
rendered paste body
<?php

function dir2arr ( $path )
{
	$dirarr = array();

	if ( ! ($handle = opendir( $path )) )
		die("Couldn't open ".$path);

	if ( ! chdir($path) )
		die("Couldn't chdir to ".$path);

	while (false !== ($file = readdir($handle)))
	{
		if ( $file == '.' || $file == '..' ) continue;

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

	chdir("..");

	closedir($handle);
	return $dirarr;
}

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

?>