range
array range(int low, int high)
Returns an array of integers from the specified starting point to the highest value specified.
Returns:
Array containing the integers from low to high
Description:
Creates an array of integers beginning with the value specified by low and increasing by one for each element until high has been reached.
Version:
PHP 3 since 3.0.8, PHP 4 since 4.0b4
Example:
Generate a range of integers
$numbers = range(1, 10);
echo "Numbers: ", implode(", ", $numbers);
Output:
Numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
|
Get PHP Functions Essential Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.