This is another my PHP snippet to create file tree array dynamically.
<?php function wps_glob($dir) { foreach (glob($dir . '/*') as $f) { if(is_dir($f)) { $r[] = array(basename($f) => wps_glob($f)); } else { $r[] = basename($f); } } return $r; } function wps_files($path) { $wpsdir = Array( 'root' => $path, 'struktur' => wps_glob($path) ); return $wpsdir; } ?>
Usage
<?php echo '<pre>'; print_r( wps_files( PATH_TO_YOUR_DIRECTORY ) ); echo '</pre>'; ?>
No comments :
Post a Comment