Minwork Array
  • Minwork Array
  • Common methods
    • has
    • get → getNestedElement
    • set → setNestedElement
    • remove
    • clone
    • getKeysArray
  • Object oriented methods
    • General information
  • Traversing array
    • Finding
    • Iterating
  • Manipulating array
    • Mapping
    • Filtering
    • Grouping
    • Sorting
    • Computations
    • Flattening
  • Validating array
    • check
    • isEmpty
    • isNested
    • isArrayOfArrays
    • isAssoc
    • isUnique
    • isNumeric
    • hasKeys
  • Utility methods
    • pack
    • unpack
    • createMulti
    • forceArray
    • getDepth
    • random
    • shuffle
    • nth
    • getFirstKey
    • getLastKey
    • getFirstValue
    • getLastValue
Powered by GitBook
On this page

Was this helpful?

  1. Utility methods

getLastKey

Definition

Arr::getLastKey(array $array): int|string|null

Description

Get the last key of the given array without affecting the internal array pointer.

Returns null if array is empty.

Examples

Arr::getLastKey(['a' => 1, 'b' => 2, 'c' => 3]) -> 'c'

Arr::getLastKey([1, 2, 3]) -> 2

Arr::getLastKey([]) -> null
PreviousgetFirstKeyNextgetFirstValue

Last updated 5 years ago

Was this helpful?