MyFault
MyFault

Reputation: 427

PHP: Remove whitespace from money_format

I'm using money_format to generate a string like 1,23€.

At first I'm using

setlocale(LC_MONETARY, 'de_DE.utf8');

If I use this:

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

I'm getting this:

1,23 €

But I would like to get this:

1,23€

(without whitespace).

How can I do this?

Upvotes: 1

Views: 395

Answers (1)

Abhishek Sharma
Abhishek Sharma

Reputation: 6661

use PHP str_replace

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

or

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

str_replace function replaces some characters with some other characters in a string

str_replace(find,replace,string)

Upvotes: 2

Related Questions