arrayutils
  • Home
  • 📖How to use?
    • âš¡Installation
  • 📖Methods
    • âš¡Static method
      • static from()
      • static of()
      • static mapToArray()
    • âš¡Generic method
      • join()
      • every()
      • some()
      • reduce()
        • reduceRight()
      • sum()
      • pop()
      • shift()
      • includes()
      • keyExists()
      • indexOf()
      • find()
        • findIndex()
      • first()
        • keyFirst()
      • last()
        • keyLast()
      • random()
        • keyRandom()
      • splice()
    • âš¡Chain method
      • chunk()
      • column()
      • combine()
      • concat()
        • concatSoft()
      • countValues()
      • diff()
        • diffAssoc()
        • diffKey()
      • fill()
        • fillKeys()
      • filter()
      • flat()
        • flatMap()
      • flip()
      • forEach()
      • intersect()
        • intersectAssoc()
        • intersectKey()
      • keys()
      • map()
        • mapAssoc()
        • mapKey()
      • pad()
      • push()
      • replace()
      • reverse()
      • slice()
      • sort()
        • sortKey()
      • unique()
      • unshift()
      • values()
  • 📖Suffixes
    • âš¡Suffix - From
    • âš¡Suffix - As
  • links
    • 📌Github repo
    • 📌Packagist project
    • 📌Poggit project
Powered by GitBook
On this page
  • Syntax
  • Return value
  • Prefixing
  • References
  1. 📖Methods
  2. ⚡Generic method
  3. first()

keyFirst()

The keyFirst() method returns first key

Previousfirst()Nextlast()

Last updated 4 years ago

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

PHP: array_key_first - Manual
Logo