Pham Minh Tan
Pham Minh Tan

Reputation: 2096

Converting a string number with Dotted Separator in PHP

I have a variable

<?php $number = "10000000"; ?>

I want convert a string to string number with dotted seperator like this: 10000000 -> 10.000.000

What can i do now? Thanks.

Upvotes: 1

Views: 159

Answers (1)

someOne
someOne

Reputation: 1675

The number_format() function formats a number with grouped thousands. For the dotted separator simply use '.' as the fourth argument:

echo number_format("10000000", 0, ",", "."); //10.000.000

Upvotes: 3

Related Questions