Home > Backend Development > PHP Tutorial > 2-101==>1,102-201==>2,202-301==>3.该如何解决

2-101==>1,102-201==>2,202-301==>3.该如何解决

WBOY
Release: 2016-06-13 13:20:25
Original
1306 people have browsed it

2-101==>1,102-201==>2,202-301==>3...
2,3,4......101===生成1
102,3,4......201===生成2
202,3,4......201===生成3
302,3,4......301===生成4
402,3,4......401===生成5

------解决方案--------------------
2,3,4......101===生成1//除外
n02,3,4......n01===生成n+1

------解决方案--------------------
$n = 2;
echo ceil(($n-1)/100);

这样就可以了,你可以自己验证一下

for($n=2; $n echo $n, ':', ceil(($n-1)/100), PHP_EOL;

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