我查看了论坛,但没有找到我需要的东西。我需要帮助从文件名中删除扩展名,并包括目录中的所有文件(例如 php 文件),并向您展示示例。
此代码有效
$name = 'file.php';
$fileName= pathinfo($name, PATHINFO_FILENAME );
echo "Name: {$fileName}";
Results:
Name: file
但是如何使用文件夹中包含的几个文件来获得它
<?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.
?>