Jump to content

[SOLVED] how do i remove Dir names on output?


jacko310592

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.