HH\Vector::firstKey

Description

public function firstKey(): ?int

Returns the first key in the current Vector.

Return Values

  • ?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.

<?hh

namespace Hack\UserDocumentation\API\Examples\Vector\FirstKey;

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

$v = Vector {};
var_dump($v->firstKey());
Output
int(0)
NULL