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

WBOY
Release: 2016-06-13 13:08:19
Original
1012 people have browsed it

个位数格式化前面加零怎么办?
循环中显示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);

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template