HH\Vector::firstKey

Returns the first key in the current Vector

public function firstKey(): ?int;

Returns

  • ?int - The first key (an integer) in the current Vector, or null if the Vector is empty.

Examples

The following example gets the first key from Vector. An empty Vector will return null as its first key.

$v = Vector {'red', 'green', 'blue', 'yellow'};
\var_dump($v->firstKey());

$v = Vector {};
\var_dump($v->firstKey());