如何在 PHP 中查找和打印两个数字之间的所有数字?
问题描述:
现在我要求用户提供两个号码.我试图打印 $one 和 $two 之间的数字,假设 $one 小于 $two.
Right now I'm asking the user for two numbers. I'm trying to print the numbers in between $one and $two assuming $one is smaller than $two.
答
只需一个简单的 for
循环即可:
Just a simple for
loop should do the trick:
for($i=$a; $i<=$b; $i++) {
echo $i;
}