相关疑难解决方法(0)

删除多个空格

$row['message']从MySQL数据库获取,我需要删除所有的空白\n \t,等等.

$row['message'] = "This is   a Text \n and so on \t     Text text.";
Run Code Online (Sandbox Code Playgroud)

应格式化为:

$row['message'] = 'This is a Text and so on Text text.';
Run Code Online (Sandbox Code Playgroud)

我试过了:

 $ro = preg_replace('/\s\s+/', ' ',$row['message']);
 echo $ro;
Run Code Online (Sandbox Code Playgroud)

但它不会删除\n\t只是单个空格.谁能告诉我怎么做?

php regex string whitespace preg-replace

196
推荐指数
8
解决办法
21万
查看次数

标签 统计

php ×1

preg-replace ×1

regex ×1

string ×1

whitespace ×1