PHP:从 money_format 中删除空格

PHP: Remove whitespace from money_format

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

一开始我在用

setlocale(LC_MONETARY, 'de_DE.utf8');

如果我使用这个:

money_format('%.2n', .23);

我明白了:

1,23 €

但我想得到这个:

1,23€

(没有空格)。

我该怎么做?

使用PHPstr_replace

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

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

str_replace函数用字符串中的一些字符替换一些字符

str_replace(find,replace,string)