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.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
range
gives an array containing all the numbers.You can iterate over that:
Or simply use a loop:
This sounds like homework...
This really gets you only the numbers between, not the endpoints.
Just a simple
for
loop should do the trick:range($one, $two) makes an array of numbers from $one to $two.
In this example, the array of numbers are first stored in $numbers before they are printed.
If $one is 5 and $two is 10 these examples will output: