123
<?php $i=0; $sum=0; for($i=0;$sum<100;$i++){ $i=$i++; $num=rand(1,6); switch($num){ case 1: case 2: case 3: case 4: case 5: echo "*****前进".$num."步"; break; default; echo "*****点数为".$num."重新rand;"; $num=0; } $sum=$sum+$num; echo "当前步数".$sum."步*****</br>"; } echo "共运行".$i."次"; ?>