- 論壇徽章:
- 0
|
例如,echo number_format(285266237);
可以輸出 285,266,237
另外如果需要格式化文件字節(jié)大小,下面的方法可以借鑒:
1: function byte_format($input, $dec=0)
2: {
3: $prefix_arr = array(' B', 'K', 'M', 'G', 'T');
4: $value = round($input, $dec);
5: $i=0;
6: while ($value>1024)
7: {
8: $value /= 1024;
9: $i++;
10: }
11: $return_str = round($value, $dec).$prefix_arr[$i];
12: return $return_str;
13: }
1: echo byte_format(285266237);
顯示結(jié)果為 272M
例如,echo number_format(285266237);
可以輸出 285,266,237
另外如果需要格式化文件字節(jié)大小,下面的方法可以借鑒:
1: function byte_format($input, $dec=0)
2: {
3: $prefix_arr = array(' B', 'K', 'M', 'G', 'T');
4: $value = round($input, $dec);
5: $i=0;
6: while ($value>1024)
7: {
8: $value /= 1024;
9: $i++;
10: }
11: $return_str = round($value, $dec).$prefix_arr[$i];
12: return $return_str;
13: }
1: echo byte_format(285266237);
顯示結(jié)果為 272M
本文來自ChinaUnix博客,如果查看原文請點:http://blog.chinaunix.net/u/6039/showart_54464.html |
|