rendered paste body<?php$dir = './tmp/';print_r(getArray($dir));function getArray($dir){ $output_f = array(); $stack = array(array('folder' => $dir, 'key' => &$output_f)); $output = &$output; while (($sp = end($stack)) !== FALSE){ $folder = $sp['folder']; $output = &$sp['key']; unset($stack[key($stack)]); $fp = opendir($folder); $key = basename($folder); while (($file = readdir($fp)) !== FALSE){ if ($file == '.' || $file == '..'){ continue; } if (is_dir($folder . '/'.$file)){ $output[$file] = array(); $stack[] = array('folder' => $folder . '/' . $file, 'key' => &$output[$file]); } else { $output[] = $file; } } closedir($fp); } return $output_f;}?>