Home  >  Article  >  Backend Development  >  新手请问PHP如何批量循环打印出四位数的数字

新手请问PHP如何批量循环打印出四位数的数字

WBOY
WBOYOriginal
2016-06-13 11:51:56818browse

新手请教PHP怎么批量循环打印出四位数的数字?
比如我要打印
0000
0001
0002
0003
......
9999
这样的四位数的数字,请问该用什么方式实现?

------解决方案--------------------

for ($i=0; $i < 10000; $i++) { <br />	echo str_pad($i, 4,'0',STR_PAD_LEFT )."<br />";<br />}

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
Previous article:对PHP输入输出流学习跟认识Next article:php 引述