简体   繁体   English

如何在PHP中将数字修剪为5位数?

[英]How would I trim a number to 5 digits in PHP?

I have a number like this: 我有这样的数字:

12345678987654321

I want to only use the first 5 digits like this: 我想只使用前5位数字:

12345

How would I do that in PHP? 我怎么用PHP做到这一点? number_format ? number_format

Something like substr($number, 0, 5); substr($number, 0, 5); would suffice. 就够了

$num = "12345678987654321";
$num2 = substr($num, 0, 5);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM