【发布时间】:2015-09-13 09:19:01
【问题描述】:
我尝试使用 PHP 的 glob() 函数列出目录的文件夹。我也用过str_replace。
这是我的代码 -
<?php
/* files directory (strukture):
*files
* folder_01
* folder_02
* test.png
* test.txt
* folder_03
*/
$file_dir = "files";
foreach(glob($file_dir.'/*', GLOB_ONLYDIR) as $dir) {
$dir = str_replace($file_dir.'/','',$dir);
echo basename($dir).PHP_EOL./*why is between the basename and the following text a space?*/">>some text<<"."<br>";
}
?>
现在我在基本名称之后得到了空格。我不想要这些空格,并且在尝试删除 basename 中的空格时需要帮助。
【问题讨论】: