YouTip LogoYouTip

Func Array Range

# PHP range() Function [![Image 3: PHP Array Reference](#)Complete PHP Array Reference](#) ## Example Create an array containing elements from "0" to "5": [Run Example Β»](#) * * * ## Definition and Usage The range() function creates an array containing elements within a specified range. The function returns an array containing 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. * * * ## Syntax range(_low,high,step_) | Parameter | Description | | :--- | :--- | | _low_ | Required. Specifies the minimum value of the array elements. | | _high_ | Required. Specifies the maximum value of the array elements. | | _step_ | Optional. Specifies the increment between elements. Default is 1. | ## Technical Details | Return Value: | Returns an array containing elements from _low_ to _high_. | | :--- | | PHP Version: | 4+ | | Changelog: | The _step_ parameter was added in PHP 5.0. In PHP versions 4.1.0 to 4.3.2, the function treated numeric strings as strings instead of integers. Numeric strings were used for character sequences, e.g., "5252" was treated as "5". Support for character sequences and descending arrays was added in PHP 4.1.0. Character sequence values were limited to a length of one. If the length was greater than one, only the first character was used. Prior to this version, range() only generated ascending integer arrays. | * * * ## More Examples ## Example 1 Return an array containing elements from "0" to "50" with an increment of 10: [Run Example Β»](#) ## Example 2 Using letters - Return an array containing elements from "a" to "d": [Run Example Β»](#) * * Complete PHP Array Reference](#)
← Func Array ResetFunc Array Prev β†’