Chen Log

陳洛格

ThinkPHP 數字格式(純數字變金錢格式)

leave a comment »

php函數為:

number_format()

<?php
echo number_format(10000);		// 输出:10,000
echo number_format(10000,2);		// 输出:10,000.00
echo number_format(10000,2,'.',' ');	// 输出:10 000.00
echo number_format(10000,2,'.','');	// 输出:10000.00
?>

 

ThinkPHP的前臺模板可以這樣使用:

{$money | number_format=0}

$money=錢
numner_format 後面的零為小數點後幾位的格式,

當然如果是 numner_format = 0 也可以不用填,直接寫成這樣:

{$money | number_format}

Advertisements

Written by chenagw

2013/06/07 at 16:59

Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: