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+ |
完整的PHP Array參考手冊