0

I have this number 1003636 and i need to convert in this format 1.003,636 how to convert with php, this is a dynamically numbers from rows of mysql.

1

2 Answers 2

1

You need to use number_format(), but there's no way of telling the function that the last 3 numbers are the decimals. So you need to first divide by 1000, and then use the function:

<?php $n = 1003636; $n /= 1000; echo number_format($n, 3, ",", "."); // 1.003,636 - 3 decimals, separate thousands by . and decimals by , 

Demo

Sign up to request clarification or add additional context in comments.

Comments

0

PHP has a build in function, number_format. http://php.net/manual/en/function.number-format.php

E.G.

$number = 1003636; echo number_format($number); // This would output 1,003,636 

Worth checking out the documentation, as their are certain parameters you can pass for dealing with foreign numbers, e.g. dots instead of commas and vice verse.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.