- The call to this function throws an exception
- false
- A to Z in alphabetical order
- The distance between A and z in the alphabet
PHP Range () function
PHP Array function
Instance
Create an array containing the range of elements from "0" to "5":
range(0,5)
;p Rint_r ();? >
Running an instance
Definition and usage
The range () function creates an array of elements that contain the specified range.
The function returns an array containing the elements from low to high.
Note: If the low parameter is greater than the high parameter, the created array will be from high to low.
Description
The function creates an array that contains integers or characters from low to high ( containing low and high). If High is smaller than low, returns an array of the inverse order.
Grammar
Range (low,High,step)
Parameters |
Description |
Low |
Necessary. Specifies the lowest value of the array. |
High |
Necessary. Specifies the highest value of the array. |
Step |
Optional. Specifies the stepping between elements. The default is 1. |
Technical details
return value: |
Returns an array containing the elements from low to high. |
PHP version: |
4 + |
Update log: |
The step parameter is added in PHP 5.0. in PHP 4.1.0 to 4.3.2, the function considers a numeric string as a string instead of an integer. Numeric strings will be used for character sequences, for example, "5252" is considered "5". Support for character sequences and decrement arrays is new in PHP 4.1.0. The value of the character sequence is limited to one length. If the length is greater than one, only the first character is used. Before this version, range () only produces an incremented array of integers. |
More examples of examples 1
Returns an array of elements that contain "0" through "50" and increment by 10:
range(0,50,10)
;p Rint_r ();? >
Running an instance
Example 2
Use letters-Returns an array containing elements from "a" to "D":
range("a","d")
;p Rint_r ($letter);? >
Running an instance
[Single topic]range (' A ', ' Z ') return what?