开发者

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 ou开发者_运维百科tput this as:

2,050

instead of

**2050** ?


number_format()

Example:

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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜