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. Common methods

get → getNestedElement

PrevioushasNextset → setNestedElement

Last updated 5 years ago

Was this helpful?

Definition

Arr::getNestedElement(array|ArrayAccess $array, mixed $keys, mixed $default = null): mixed

Aliases

get($array, $keys, $default = null) -> getNestedElement($array, $keys, $default)

Description

Get nested array element using specified keys or return $default value if it does not exists.

$keys argument is parsed using method

Examples

$array = ['key1' => ['key2' => ['key3' => ['test']]]];

Arr::getNestedElement($array, 'key1.key2.key3') -> ['test']

Arr::getNestedElement($array, 'key1.key2.key3.0') -> 'test'

Arr::getNestedElement($array, ['nonexistent', 'key'], 'default') -> 'default'

Arr::getNestedElement($array, 'nonexistent.key.without.default') -> null
getKeysArray