求助:我这样的ID怎么转换
我这这样的一组ID字符串
10
1010
10122233
我想转换成 下面的整型数
10 000 000 000
10 100 000 000
10 122 233 000
请问一下,这样的算法,我怎么写一下。
最好是有一个方法。
------解决方案--------------------
str_pad
------解决方案--------------------
$s = '10122233';
$s = str_pad($s, 11, '0');
$t = number_format($s);
echo join(' ', explode(',', $t));
------解决方案--------------------
$str1='10'; $str2='1010'; $str3='10122233'; //10 000 000 000 //10 100 000 000 //10 122 233 000 echo str_pad($str1, 11,'0').'<br>'; echo str_pad($str2, 11,'0').'<br>'; echo str_pad($str3, 11,'0').'<br>'; <br><font color="#e78608">------解决方案--------------------</font><br>str_pad(string,length,pad_string,pad_type)//str_pad() 函数把字符串填充为指定的长度。 <div class="clear"></div>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号