jacko310592 Posted November 18, 2009 Share Posted November 18, 2009 hey eveyone, i have this code which shows all the files it can find within a directory, it also gets files from all subdirectories it finds... <?php $files = new RecursiveDirectoryIterator("gallery"); foreach(new RecursiveIteratorIterator($files) as $files) { echo ''.$files.'<br/>'; } ?> which outputs as follows.. gallery\subDir1\DSCF5926.jpg gallery\subDir1\DSCF5950.jpg gallery\subDir1\DSCF5952.jpg gallery\subDirTwo\DSCF1704.jpg gallery\subDirTwo\DSCF1749.jpg my problem is that id like to remove the directory names (eg. gallery\subDirTwo\) from the output so im just left with the file names. i know of the code which removes characters from an output $files = substr($files,30); but i cannot use this method as my subdirectories (dirs under 'gallery') all have different name lengths. can anyone think of a way the directory names can be removed? thanks guys Link to comment https://forums.phpfreaks.com/topic/182037-solved-how-do-i-remove-dir-names-on-output/ Share on other sites More sharing options...
cags Posted November 18, 2009 Share Posted November 18, 2009 Sounds like a job for basename. Link to comment https://forums.phpfreaks.com/topic/182037-solved-how-do-i-remove-dir-names-on-output/#findComment-960196 Share on other sites More sharing options...
jacko310592 Posted November 18, 2009 Author Share Posted November 18, 2009 wow, that was simple, thanks allot cags, havnt heard of 'basename' before Link to comment https://forums.phpfreaks.com/topic/182037-solved-how-do-i-remove-dir-names-on-output/#findComment-960202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.