Hi everyone.
Okay... I'm using this code to display the files from a directory:
$files = array();
$dir = opendir("./categories");
while(($file = readdir($dir)) !== false) {
if($file !== '.' && $file !== '..' && !is_dir($file)) {
$files[] = $file;
}
}
closedir($dir);
sort($files);
for($i=0; $i<count($files); $i++) {
$it = str_replace("_", " ", $files[$i]); // replace underscore with whitespace
echo "<a href=\"index.php?op=view_category&cat=$files[$i]\">$it<br>";
}
It displays the files, but I haven't programed PHP in a really long time. How would I be able to remove the file extensions? For example, it displays like this:
FILE1.TXT
FILE2.TXT
FILE3.TXT
FILE4.TXT
FILE5.TXT
Thanks alot. Any help will be greatly appreciated.
-Calvin