Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何替换shell_exec return中的空白?_Php_Html_Linux_Bash - Fatal编程技术网

Php 如何替换shell_exec return中的空白?

Php 如何替换shell_exec return中的空白?,php,html,linux,bash,Php,Html,Linux,Bash,我将php函数shell_exec与ls命令一起使用: shell_exec('ls'); 报税表为: index.php index.php~ ajaxF.php ajaxF.php~ ajaxL.php ajaxL.php~ ajax.php 我注意到每个文件之间都有一个空格,我试图更改它,但失败了(“a”它只是一个随机字符,实际上我想添加一些html): preg_replace(“//”、“A”、$output); preg_replace(“//”、“A”、$output); pr

我将php函数shell_exec与ls命令一起使用:

shell_exec('ls');
报税表为:

index.php index.php~ ajaxF.php ajaxF.php~ ajaxL.php ajaxL.php~ ajax.php
我注意到每个文件之间都有一个空格,我试图更改它,但失败了(“a”它只是一个随机字符,实际上我想添加一些html):

preg_replace(“//”、“A”、$output);
preg_replace(“/
/”、“A”、$output); preg_replace(“/\n/”、“A”、$output);
如何用任何其他字符替换此空白? 这意味着为每一行添加html数据

可以拆分数组中的每一行吗

顺便说一下,我正在使用ubuntu

谢谢

为什么不使用
glob('*')
,它将返回当前目录中的文件数组?然后,您可以使用infrade()并插入所需的任何分隔符char/文本

ref:

为什么不使用
glob('*')
,它将返回当前目录中的文件数组?然后,您可以使用infrade()并插入所需的任何分隔符char/文本


参考:

谢谢!比我想象的要好!谢谢比我想象的要好!
preg_replace('/ /', "A", $output);
preg_replace('/<br>/', "A", $output);
preg_replace('/\n/', "A", $output);