rrylee
9/7/2015 - 3:10 PM

RecursiveTreeIterator 生成树状文件结构

RecursiveTreeIterator 生成树状文件结构

<?php

$files = new RecursiveDirectoryIterator('common');
$files->setFlags(RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::UNIX_PATHS);
$files = new RecursiveTreeIterator($files);
$files->setPrefixPart(RecursiveTreeIterator::PREFIX_LEFT, '&divideontimes;');
$files->setPrefixPart(RecursiveTreeIterator::PREFIX_END_HAS_NEXT, '&Vdash;');
$files->setPrefixPart(RecursiveTreeIterator::PREFIX_END_HAS_NEXT, '&wr;');
$files->setPrefixPart(RecursiveTreeIterator::PREFIX_END_LAST, '&acd;');

foreach ($files as $file) {
    echo $file . '<br />';
}