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

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

WBOY
Release: 2016-06-23 14:00:32
Original
1009 people have browsed it

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


回复讨论(解决方案)

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

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

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

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


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

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

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

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