(PHP 5 >= 5.1.0, PHP 7, PHP 8)
RecursiveDirectoryIterator::getSubPathname — 取得子路徑和名稱
此函式沒有參數。
子路徑(子目錄)和檔案名稱。
範例 #1 getSubPathname() 範例
$directory = '/tmp';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
foreach ($it as $file) {
echo '子路徑名稱:' . $it->getSubPathname() . "\n";
echo '子路徑:' . $it->getSubPath() . "\n\n";
}
上述範例將輸出類似以下的內容
SubPathName: fruit/apple.xml SubPath: fruit SubPathName: stuff.xml SubPath: SubPathName: veggies/carrot.xml SubPath: veggies