I am using php print to display all the files in a certain directory. How can i change this to hide the file extension.
<?php
// opens this directory
$myDirectory = opendir(".");
// gets each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// finds extention of file
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
// closes directory
closedir($myDirectory);
// counts elements in array
$indexCount = count($dirArray);
// sorts files
sort($dirArray);
// print 'em
print("<table width='auto' cellspacing='0'>
\n");
// loops through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<ul><a href='$dirArray[$index]'>$dirArray[$index]</a></ul>");
}
}
print("</table>\n");
?>
<?php
// opens this directory
$myDirectory = opendir(".");
// gets each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// finds extention of file
function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
// closes directory
closedir($myDirectory);
// counts elements in array
$indexCount = count($dirArray);
// sorts files
sort($dirArray);
// print 'em
print("<table width='auto' cellspacing='0'>
\n");
// loops through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<ul><a href='$dirArray[$index]'>$dirArray[$index]</a></ul>");
}
}
print("</table>\n");
?>