Open sub directories and only files with "xyz.html"

Hi all,

I want to accomplish :to open a sub directory from “/home/www/htdocs/icm/sessions” -> there are sub folders in sessions and in those folders there are “chromatin.html” files which i want them to populate in a dropdown box.

I am not able to open the files as i intended to, Please let me know where I am doing it wrong

<?php echo ""; $files = scandir("/home/www/abc/def/seq"); foreach ($files as $file){ $ext = substr($file, -4); if(strtolower($ext) == 'xyz.html') { $file = substr($file, 0, strrpos($file, '.')); echo '' . $file . ''; } } echo ""; ?>

Need help :frowning:

try using GLOB instead,
[php]<?php
echo “<select name=‘files’ , fixedscript, id=‘file_selector’>”;

foreach (glob("/home/www/abc/def/seq/*.html") as $file){
$ext = substr($file, -4);

if(strtolower($ext) == ‘xyz.html’) {
echo ‘’ . $file . ‘’;
}
}
echo “”;
?>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service