All pastes #644303 Raw Edit

Miscellany

public php v1 · immutable
#644303 ·published 2007-08-03 13:40 UTC
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;}?>