I looked on the forums but did not find what I need. I need help to delete the extension from the file name, and include all files for example (php files) from a directory, and show you examples.
This code work
$name = 'file.php';
$fileName= pathinfo($name, PATHINFO_FILENAME );
echo "Name: {$fileName}";
Results:
Name: file
but how do I get this with several files included in the folder
<?php
$dir = "/dir1/dir2/dir3/dir4/";
$phpfiles = glob($dir . "*.php");
foreach ($phpfiles as $phpfile){
echo '<li><a href="'.$phpfile.'">'.basename($phpfile,".php").'</a></li>';
}
output
1.php
2.php
3.php
4.php
-----------------
how to insert path info in this script so that all files are included without extensions.
?>
By using pathinfo function...??