PHP key() 函數
實例
從當前內部指針位置返回元素鍵名:
<?php
$people=array("Peter","Joe","Glenn","Cleveland");
echo "The key from the current position is: " . key($people);
?>
$people=array("Peter","Joe","Glenn","Cleveland");
echo "The key from the current position is: " . key($people);
?>
定義和用法
key() 函數從當前內部指針位置返回元素鍵名。
如果錯誤,函數返回 FALSE。
語法
key(array)
參數 | 描述 |
---|---|
array | 必需。規定要使用的數組。 |
技術細節
返回值: | 返回當前內部指針所指向的數組元素的鍵名。 |
---|---|
PHP 版本: | 4+ |
