145 of 410 menu

The array_keys Function

The array_keys function retrieves the keys of an array and writes them to a new array.

Syntax

array_keys(array $array, mixed $search_value = null, bool $strict = false): array

Example

Let's get the keys from the array:

<?php $arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5]; $res = array_keys($arr); var_dump($res); ?>

Code execution result:

['a', 'b', 'c', 'd', 'e']

See Also

byenru