Anemone::first()

Returns the first item in the data.

Table of Contents
  1. Description
  2. Example

Description

Anemone::first(bool $take = false): mixed;

This method returns the first item in the data. Optionally, takes it from the current data. If the data is empty, this method returns null. It does not modify the data.

Example

$anemone = new Anemone([1, 2, 3, 4, 5]);

$first = $anemone->first(); // Returns `1`
$all = $anemone->get(); // Returns `[1, 2, 3, 4, 5]`

$first = $anemone->first(true); // Returns `1`
$all = $anemone->get(); // Returns `[2, 3, 4, 5]`
$anemone = new Anemone([
    'a' => 1,
    'b' => 2,
    'c' => 3,
    'd' => 4,
    'e' => 5
]);

$first = $anemone->first(); // Returns `1`
$all = $anemone->get(); // Returns `['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5]`

$first = $anemone->first(true); // Returns `1`
$all = $anemone->get(); // Returns `['b' => 2, 'c' => 3, 'd' => 4, 'e' => 5]`

Anemone::any()

Checks if at least one item in the data passes the test.

Anemone::first()

Returns the first item in the data.

Anemone::is()

Filters the data so that only items that pass the test are left.

Anemone::not()

Filters the data so that only items that do not pass the test are left.

Anemone::pluck()

Returns a new data set contains values from the key on every item.