UK[ki:] US[ki]

n.Key; (of a typewriter, etc.) key; key, clue, secret; (of music) key

vt.Type; Lock; adjust the tone of...; provide clues

vi. Use keys

adj. Critical; main

Third person singular: keys Plural: keys Present participle: keying past tense: keyed past participle: keyed

php key() function syntax

Function: Returns the key name of the element currently pointed to by the internal pointer of the array.

Syntax: key(array)

Parameters:

Parameter Description
arrayRequired. Specifies the array to use.

Description: Returns the key name of the element currently pointed to by the internal pointer of the array. If an error occurs, the function returns FALSE.

php key() function example

<?php
$people = array("西門", "滅絕", "無忌");
echo "鍵的當(dāng)前位置是:" . key($people);
?>

Run instance?

Click the "Run instance" button to view the online instance

Output:

鍵的當(dāng)前位置是:0


<?php
$arr = array("西門", "滅絕", "無忌");
$arr2 = next($arr);  //指向下一個(gè)元素 滅絕
echo key($arr);      //輸出滅絕的 key值
?>

Run Instance?

Click the "Run Instance" button to view the online instance

Output:

1