1
我喜歡在包含子目錄的目錄中獲取所有.less文件。我在php.net找到了這個漂亮的代碼。RecursiveDirectoryIterator + RecursiveIteratorIterator + RegexIterator不能像他們應該那樣工作
我做錯了什麼?有什麼改變?這個例子錯了嗎?它看起來像第一個發現一個.less.bak文件。
$Directory = new RecursiveDirectoryIterator(CHILD_DIR . '/less');
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '/^.+\.less$/i', RecursiveRegexIterator::GET_MATCH);
print_r($Directory );
print_r($Iterator );
print_r($Regex );
輸出如下:
RecursiveDirectoryIterator Object
(
[pathName:SplFileInfo:private] => /var/www/secret/wayne/wp-content/themes/bootgen_child/less/bootgen_layout.less.bak
[fileName:SplFileInfo:private] => bootgen_layout.less.bak
[glob:DirectoryIterator:private] =>
[subPathName:RecursiveDirectoryIterator:private] =>
)
RecursiveIteratorIterator Object
(
)
RegexIterator Object
(
[replacement] =>
)
好的,謝謝,我腦子裏想約的東西,因爲第一個只包含一個本辦法。我需要更多的編程經驗 – amy