Home  >  Article  >  Backend Development  >  带千分位和小数位的数据写入数据库的有关问题

带千分位和小数位的数据写入数据库的有关问题

WBOY
WBOYOriginal
2016-06-13 12:24:56904browse

带千分位和小数位的数据写入数据库的问题
310
1,000.00
2,000


上面三个数据,写入数据库是310,1,2,有什么正确的方法写入数据库呢~
------解决思路----------------------

$num = 千分位的数字;<br />$num .= ''; //转为字符串<br />$newnum = str_replace(',', '', $num);<br />$newnum += 0; //转为数字<br />

------解决思路----------------------
str_replace()替换就可

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn