Skip to content

Kirby 5.0.4

A::get()

Gets an element of an array by key

A::get(array $array, string|int|array|null $key, mixed $default = null)

Parameters

Name Type Default Description
$arrayrequired array no default value The source array
$key stringorintorarrayornull no default value The key to look for
$default mixed null Optional default value, which
should be returned if no element
has been found

Parent class

Kirby\Toolkit\A

Examples

$array = [
  'cat'  => 'miao',
  'dog'  => 'wuff',
  'bird' => 'tweet'
];