# range

Create an array containing a range of elements

## Syntax

`range ( mixed \$start , mixed \$end [, number \$step = 1 ] ) : array`

### Parameters

`start`

First value of the sequence.

`end`

The sequence is ended upon reaching the end value.

`step`

If a step value is given, it will be used as the increment between elements in the sequence. step should be given as a positive number. If not specified, step will default to 1.

### Return

Returns an array of elements from start to end, inclusive.

## Examples

### start end | Numeric | Ascend

```<?

\$start = 0;
\$end = 9;

\$return = range(\$start, \$end);

print_r(\$return);

?>```
```Array
(
 => 0
 => 1
 => 2
 => 3
 => 4
 => 5
 => 6
 => 7
 => 8
 => 9
)
```

### start end | Numeric | Descend

```<?

\$start = 9;
\$end = 0;

\$return = range(\$start, \$end);

print_r(\$return);

?>```
```Array
(
 => 9
 => 8
 => 7
 => 6
 => 5
 => 4
 => 3
 => 2
 => 1
 => 0
)
```

### start end | Alphabetic | Ascend

```<?

\$start = "a";
\$end = "j";

\$return = range(\$start, \$end);

print_r(\$return);

?>```
```Array
(
 => a
 => b
 => c
 => d
 => e
 => f
 => g
 => h
 => i
 => j
)
```

### start end | Alphabetic | Descend

```<?

\$start = "j";
\$end = "a";

\$return = range(\$start, \$end);

print_r(\$return);

?>```
```Array
(
 => j
 => i
 => h
 => g
 => f
 => e
 => d
 => c
 => b
 => a
)
```

### step

```<?

\$start = 0;
\$end = 9;
\$step = 3;

\$return = range(\$start, \$end, \$step);

print_r(\$return);

?>```
```Array
(
 => 0
 => 3
 => 6
 => 9
)
```  