I've been working on a php dynamic drop down list that scans a folder on the web server and list its contents it works hears relevant selection of the code.
<?php
foreach(glob(dirname(rootdir) . '/path/username/*') as $filename){
$filename = basename($filename);
echo "<option value='filepath/username/" . $filename . "'>".$filename."</option>";
}
?>
However if i use a variable to populate part of the file path the variable doesn't get added to the path.
<?php
$name = "jsmith";
foreach(glob(dirname(rootdir) . '/path/$name/*') as $filename){
$filename = basename($filename);
echo "<option value='filepath/$name/" . $filename . "'>".$filename."</option>";
}
?>
$name = "jsmith"
The result I'm looking for is /path/$name/* = /path/jsmith/ and filepath/$name/ = filepath/jsmith/
How do I get the glob(dirname) and option value=' recognize the variables?