Home > Backend Development > PHP Tutorial > 格式化数字的方法?

格式化数字的方法?

WBOY
Release: 2016-06-23 14:26:01
Original
798 people have browsed it

比如0.21951100 ,我只想取得小数点后面的数字,则是21951100,不用explode函数能实现吗?


回复讨论(解决方案)

转成字符串类型 然后通过substring 截取小数点后面数字 

方法很多

随便举一个

$a = "0.21951100";echo substr($a,strpos($a,".")+1);
Copy after login


21951100

另求当

$a = 0.21951100; //此时$a是数字类型//从这里开始还有没有可能知道0.219511后边还有两个0?
Copy after login

最强大家,直接str_replace ,分给我,不谢。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template