-
-
Save rainbow23/c32f1a6e31256ff67f3c0a438edc0bf4 to your computer and use it in GitHub Desktop.
ループで0-4になる対応の改善案
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$sample = array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20); | |
$begin = 0; | |
$end = 5; | |
/* | |
* 0 | |
* 1 | |
* 2 | |
* 3 | |
* 4 | |
*/ | |
$begin = 0; | |
$end = 10; | |
/* | |
* 0 | |
* 1 | |
* 2 | |
* 3 | |
* 4 | |
* 5 | |
* 6 | |
* 7 | |
* 8 | |
* 9 | |
*/ | |
$begin = 0; | |
$end = 20; | |
$cnt = 0; | |
foreach ($sample as $each) { | |
if ($cnt >= $begin && $cnt < $end) { | |
echo $each.PHP_EOL; | |
} | |
$cnt++; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment