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 "键的当前位置是:" . key($people);
?>

Run instance»

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

Output:

键的当前位置是:0


<?php
$arr = array("西门", "灭绝", "无忌");
$arr2 = next($arr);  //指向下一个元素 灭绝
echo key($arr);      //输出灭绝的 key值
?>

Run Instance»

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

Output:

1