arrayutils
Search…
⌃K

keyFirst()

The keyFirst() method returns first key
Example.php
<?php use kim\present\utils\arrays\ArrayUtils;
​
$arrayUtils = ArrayUtils::from(["Apple" => 0, "Banana" => 1, "Carrot" => 2]);
​
//Gets first key
$arrayUtils->keyFirst();
// expected output: "Apple"

Syntax

$arrayUtils->keyFirst() : int|string|null;

Return value

  • A first key of array. If array is empty, returns NULL.

Prefixing

ArrayUtils::keyFirstFrom(iterable $from) : int|string|null;

References

​
Last modified 2yr ago