扫码一下
查看教程更方便
key() 函数从当前内部指针位置返回元素键名:
<?php
$people=array("Peter","Joe","Glenn","Cleveland");
echo "The key from the current position is: " . key($people);
?>
执行结果
The key from the current position is: 0
key() 函数从当前内部指针位置返回元素键名。
如果错误,函数返回 FALSE。
key(array)
| 参数 | 描述 |
|---|---|
| array | 必需。规定要使用的数组。 |