从零开始学PHP第七天

嗯,一直知道用for可以来递增,但是具体怎么用就不清楚了,所以还是记一笔.

for ($i = 1; $i <= 100; $i++) {
echo $i.'
‘;
}
?>

后来问奶罩如何实现000001,000002这样的方式,奶罩说有个函数叫str_pad的.于是,就改成这样可以实现了.

for ($i = 1; $i <= 10; $i++) {
$i = str_pad($i, 6, "0", STR_PAD_LEFT);//6是总位数,0是不足6位补进去的数字,STR_PAD_LEFT表示0插左边,默认是插右边好像.
echo $i.'
‘;
}
?>

3 Responses to 从零开始学PHP第七天

  1. 赵明亮 says:

    学了3,4年了,还没学会皮毛,俺做事没毅力 :em15:

  2. 安吉洛 says:

    哇..小样..学程序喽…

  3. lee says:

    终于看到你的新作了.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>