Skip to content

IEnumerable.take() method

Marcel Kloubert edited this page Sep 25, 2015 · 2 revisions

IEnumerable->take($count) method

Takes a number of elements (s. Take()).

Syntax

public function take(int $count) : IEnumerable;

Parameters

Name Type Description
$count int The number of elements to take.

$count

The number of elements to take.

Result

The new sequence.

Examples

use \System\Linq\Enumerable;

$seq = Enumerable::fromValues(239, 5979, 1);

foreach ($seq->take(2) as $item) {
    // [0] 239
    // [1] 5979
}
Clone this wiki locally