如何在 PHP 中查找和打印两个数字之间的所有数字? [英] How can I find and print all of the numbers between two numbers in PHP?
本文介绍了如何在 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;
}
这篇关于如何在 PHP 中查找和打印两个数字之间的所有数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文