0

If you example I have this php:

$var  = $_POST['somefield'];

and suppose the value of 'somefield' is 2050, how do I make php output this as:

2,050

instead of

**2050** ?
1
  • maybe edit your question?? 2,050 instead of 2,050 ? My gosh they are same. Commented Aug 23, 2011 at 17:30

2 Answers 2

3

number_format()

Example:

// assuming US format
echo number_format($_POST['somefield']);
Sign up to request clarification or add additional context in comments.

Comments

0

Assuming you meant: "2,050 instead of 2050"

Now you want to format the no, so that thousands are seperated by commas. Please have a look at This.

And as for your code you can do this (but please read that link before)

$var = $_POST['somefield'];
$var = number_format($var);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.