Home  >  Article  >  Backend Development  >  个位数格式化前面加零怎么处理

个位数格式化前面加零怎么处理

WBOY
WBOYOriginal
2016-06-13 13:08:191010browse

个位数格式化前面加零怎么办?
循环中显示1、2、3、4。。。想显示成01、02、03、04。。。

怎么弄呢? ($no=0; $no++;显示的是单个的)

------解决方案--------------------
for($i=0;$i{
if($i echo "0" . $i;
else
echo $i;
echo "
";
}
?>
------解决方案--------------------
echo sprintf("%02s",5);
printf("%02s",9);

Statement:
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