相关疑难解决方法(0)

在PHP和数字格式中将setlocale设置为fr-FR

我正在尝试创建一个我的网站的法语版本.我已经设置setlocale(LC_ALL, 'fr_FR');在我的页面顶部,并使用strftime我正在以法国风格正确显示日期.

但是我遇到了一些问题.部分页面使用我从Web服务获取的数据.我正在为这样的var分配一个返回值:

$overallRating = $returnArray['Overall'];
Run Code Online (Sandbox Code Playgroud)

然后我使用以下代码将其格式化为1位小数

number_format($overallRating,1)
Run Code Online (Sandbox Code Playgroud)

在英文版本中,overallRating值可能是7.5并且返回一个值,例如7.5(通过number_format运行它的原因是它返回7我希望它显示7.0)

但是在法语版本中,如果我打印出原始的$ overallRating值,我会7,5看到它已将其翻译成法语.这样会好的,但是如果我运行它number_format会得到错误:

Notice: A non well formed numeric value encountered in /sites/index.php  on line 250
Run Code Online (Sandbox Code Playgroud)

第250 number_format行是该行

我认为翻译7,5是搞乱的,但不知道如何解决这个问题......

使用PHP 5.3以防有任何新的东西可以帮助我

php locale number-formatting

4
推荐指数
1
解决办法
9611
查看次数

标签 统计

locale ×1

number-formatting ×1

php ×1