PHP key() Function

Definition

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

Syntax

PHP key() Function has the following syntax.

key(array)

Parameter

ParameterIs RequiredDescription
arrayRequired.Array to use

Return

This function returns FALSE on error.

Example 1

Return the element key from the current internal pointer position:


<?php
$people=array("A","B","C","D");
echo "The key from the current position is: " . key($people);
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions