PHP中把整数2转成字符串’000002′, 使它成为6位的字符串

最初发表于: 2019-12-10 19:29:43

示例代码如下

<?php
   $number = 2;
   var_dump(sprintf("%06d", $number));

   $number = 20;
   var_dump(sprintf("%06d", $number));