修剪 使用 PHP [英] Trim   with PHP

查看:51
本文介绍了修剪 使用 PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的句子.

1       2     3   4

如您所见,在 1 2 和 3 文本之间,有额外的空格.我希望输出之间只有一个空格.所以我的输出将是 1 2 3 4.

As you see, in between 1 2 and 3 text, there are extra spaces. I want the output with only one space between them. so my output will be 1 2 3 4.

如果我使用trim,它只能删除空格,但不能删除  如何使用PHP trim 函数来获得这样的输出?

If I use trim, it can only remove white space, but not that   How can I use PHP trim function to get the output like this?

推荐答案

$str = "1 $nbsp;     2     3   4";
$new_str = str_replace(" ", '', $str);

这篇关于修剪 使用 PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆