Take

Take ( int $amount )

Returs the first amount input values, discarding the remaining values.

Parameters

amount
The amount of input values to take.

Examples

Example #1

Basic usage example.

<?php
use Webbhuset\Pipeline\Constructor as F;

$take = F::Take(2);

$input = [1, 3, 5, 7, 9];

echo json_encode(iterator_to_array($take($input)));

// Output: [1,3]

See Also

  • Drop - Discard a specific amount of input values.
  • TakeWhile - Return input values while a callback function returns true.