PHP key() Function


Complete PHP Array Reference

Definition and Usage

The key() function returns the element key from the current internal pointer position.

This function returns FALSE on error.

Syntax

key(array)

Parameter Description
array Required. Specifies the array to use


Example

<?php
$people = array("William", "Yousuf", "Glenn", "Romain");
echo "The key from the current position is: " . key($people);
?>

The output of the code above will be:

The key from the current position is: 0


Complete PHP Array Reference
Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!