PHP Array key() Function
Last Updated : 17 Mar 2025
The key( ) function returns the element key from the current internal pointer position. This function was introduced in 4.0.
Syntax
Parameter
| Parameter | Description | Is compulsory |
|---|---|---|
| array | Specifies the array to use. | compulsory |
Returns
The key( ) returns the key of the array element that is currently being pointed by the internal pointer.
Example 1
Output:
The key from the current position is: 0
Example 2
Output:
Current position Key is : Subject1
Example 3
Output:
Current position Key is :tata
Example 4
Output:
The key from the current position is: 0
Next TopicPhp-array-key-last-function