我的帖子数据中有一个数字 10,000
,我想将其存储在数据库中 10000.00
我目前有以下内容:(在 Kohana 中)
number_format(input::post('amount'),2,'.','');
但这给了我错误:
ErrorException [ Notice ]: A non well formed numeric value encountered
自 $_POST['amount']
= 10,000
有什么建议可以解决这个问题吗?
最佳答案
逗号导致了问题,您可以使用 str_replace 将其删除
number_format(str_replace(',', '', input::post('amount')), 2, '.', '');
关于php - 使用 number_format 将发布的值转换为十进制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22605644/