dweerwerw
dweerwerw

Reputation: 15

Transform output of Php

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** ?

Upvotes: 0

Views: 47

Answers (2)

DivinesLight
DivinesLight

Reputation: 2415

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);

Upvotes: 0

Jason McCreary
Jason McCreary

Reputation: 72971

number_format()

Example:

// assuming US format
echo number_format($_POST['somefield']);

Upvotes: 3

Related Questions