Home  >  Article  >  Backend Development  >  新手请教PHP怎么批量循环打印出四位数的数字?

新手请教PHP怎么批量循环打印出四位数的数字?

WBOY
WBOYOriginal
2016-06-23 14:00:32970browse

比如我要打印
0000
0001
0002
0003
......
9999
这样的四位数的数字,请问该用什么方式实现?


回复讨论(解决方案)

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

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

不知道怎么回事,语法有错误~

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


是我的问题,已经解决。感谢了!

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

另外,怎么判断有没有重复的数字,
比如:11,22,333,880,646。只要符号两个数字为相同的话,即为真。

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