Page 1 of 1

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

Posted: Fri Jul 18, 2014 6:19 pm
by arvi608
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

Code: Select all

<?php

echo "<select name='files' , fixedscript, ID='file_selector'>";


$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 '<option value="' . $file . 'xyz.html">' . $file . '</option>';
}
}
echo "</select>";



?>

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

Posted: Fri Jul 18, 2014 7:17 pm
by Celauran
arvi608 wrote:

Code: Select all

$ext = substr($file, -4);

if(strtolower($ext) == 'xyz.html') {
That's not ever going to be true. You're taking the last four characters of the filename and then checking if those four characters equal an eight character string.