(PHP 5 >= 5.1.0, PHP 7, PHP 8)
RecursiveDirectoryIterator::getSubPath — Get sub path
Returns the sub path relative to the directory given in the constructor.
This function has no parameters.
The sub path.
Example #1 getSubPath() example
$directory = '/tmp';
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
foreach ($it as $file) {
echo 'SubPathName: ' . $it->getSubPathName() . "\n";
echo 'SubPath: ' . $it->getSubPath() . "\n\n";
}
The above example will output something similar to:
SubPathName: fruit/apple.xml SubPath: fruit SubPathName: stuff.xml SubPath: SubPathName: veggies/carrot.xml SubPath: veggies
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant