PHP:从money_format中删除空白


PHP: Remove whitespace from money_format

我正在使用money_format生成类似1,23€的字符串。

一开始我使用

setlocale(LC_MONETARY, 'de_DE.utf8');

如果我使用这个:

money_format('%.2n', $1.23);

我得到这个:

1,23 €

但我想得到这个:

1,23€

(没有空格)。

我该怎么做?

使用PHP str_replace

str_replace(' €','€','1,23 €')

str_replace(' ','','1,23 €')

str_replace函数用字符串中的其他字符替换某些字符

str_replace(find,replace,string)