I l@ve RuBoard Previous Section Next Section

key

mixed key(array array) 

Returns the key for the element in the current position.

Returns:

Key of the current array element; FALSE on error

Description:

key() is used to retrieve the key of the element to which the internal array pointer is currently set.

Version:

PHP 3, PHP 4

See also:

current() 
end() 
next() 
prev() 
reset() 

Example:

Fetch the key of the current array element
$my_array = array("x" => "two", "z" => "four", "y" => "three", "w" => "one"); 
do {
   echo "Key: ", key($my_array), "\n"; 
} while (each($my_array)); 

Output: 
Key: x 
Key: z 
Key: y 
Key: w 
    I l@ve RuBoard Previous Section Next Section