https://www.youtube.com/watch?v=ROZfJ7svQH0
youtube教學
http://php.net/manual/en/control-structures.do.while.php
1. do {...} while (0);(不懂)
<?phpdo {
if ($i < 5) {
echo "i is not big enough";
break;
}
$i *= $factor;
if ($i < $minimum_limit) {
break;
}
echo "i is ok";
/* process i */} while (0);?>
Don't worry if you don't understand this right away or at all. You can code scripts and even powerful scripts without using this 'feature'. Since PHP 5.3.0, it is possible to use goto operator instead of this hack.
2. for loop條件可以空著另外寫,或寫兩個以上條件如
for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i, $i++);
或
for($i = 0, $size = count($people); $i < $size; ++$i) {
$people[$i]['salt'] = mt_rand(000000, 999999);
}
3. Looping through letters is possible.
for($col = 'R'; $col != 'AD'; $col++) {
echo $col.' ';
}
returns: R S T U V W X Y Z AA AB AC
Take note that you can't use $col < 'AD'. It only works with !=
Very convenient when working with excel columns.
沒有留言:
張貼留言