[英]remove spaces with listing folders using glob()
我試圖用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>";
}
?>
現在,我在基名之后得到空格。 我不需要空格,因此需要嘗試刪除基名中的空格的幫助。
那是因為您的PHP_EOL
。 當將其呈現為HTML時,它將成為所謂的空格 ,它將簡單地顯示為空格。 刪除它,您會很高興的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.