Links
The problem with your code is that you haven't escaped the quotation marks "
correctly in your echo
...
foreach(glob("./path/to/file/{*.ext}", GLOB_BRACE) as $file) {
echo "<li><a href=\"".pathinfo($file, PATHINFO_FILENAME).".php\">".pathinfo($file, PATHINFO_FILENAME)."</a></li>";
}
OR use single quotes '
foreach(glob("./path/to/file/{*.ext}", GLOB_BRACE) as $file) {
echo '<li><a href="'.pathinfo($file, PATHINFO_FILENAME).'.php">'.pathinfo($file, PATHINFO_FILENAME).'</a></li>';
}
Upper case first letter(s)
As for the second part of your question if you're looking to just make the firs letter upper-case then (as ali A suggested) you can use the php function ucfirst
. If you want to put the file name to title case then you can use ucwords
instead.
$a = "filename";
$b = "this file name";
echo ucfirst($a); // Filename
echo ucwords($a); // Filename
echo ucfirst($b); // This file name
echo ucwords($b); // This File Name