Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像这样的数字(作为字符串):1.00000
我怎样才能重新格式化这些数字,使其看起来像1?
谢谢
采用number_format()
number_format()
echo number_format('1.000000'); // prints 1
或使用intval()
intval()
echo intval('1.000000'); // prints 1
或将其转换为整数
echo (int) '1.000000'; // prints 1
你可以使用 floor 方法让它保持浮动
floor(1.000000)