Skip to content

Enumerable.range() method

Marcel Kloubert edited this page Jan 26, 2015 · 2 revisions

Enumerable::range($start, $count [, $increaseBy]) method

Generates a new sequence of numbers within a specified range. (s. Range()).

Syntax

public static Enumerable range(number $start, int $count [, mixed $increaseBy]);

Parameters

Name Type Description
$start number The start value.
$count int The number of items.
$increaseBy number|callable [OPTIONAL] The value for increasing to next value or the function that provides that value. The DEFAULT value is 1.

Result

The new instance.

Examples

use \System\Linq;

// 1 - 10
$seq1 = Enumerable::range(1, 10);

// 2 - 20
$seq2a = Enumerable::range(2, 10, 2);

// other way to do this
$seq2b = Enumerable::range(2, 10,
                           function($currentValue, $index) {
                               return 1 + 1;
                           });
Clone this wiki locally