
正文
php保留二位小数据库,php 保留一位小数
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
PHP保留两位小数的几种方法
int inthestr(char *s,char ch)
{
while(*s!='\0'){
if(*s==ch)
return 1;
s++;
}
return 0;
}
相关问答
Q1: php 如何保留2位小数
今天处理数据的时候因为要保留2位小数,查看帮助手册
?php
$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,235
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
// english notation without thousands seperator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?
Q2: 请问:我PHP网站,mysql数据库,要让数字后保留2位小数点,如何设置?在数据库里设置?还是网页里设置?
最佳的方式是用PHP的函数;
round(x,prec):round() 函数对浮点数进行四舍五入。
参考






