array_key_first() - Gets the first key of an array - php 数组函数
array_key_first()
(PHP 7 >= 7.3.0)
Gets the first key of an array
说明
array_key_first(array $array): mixedGet the first key of the given$arraywithout affecting the internal array pointer.
参数
$arrayAn array.
返回值
Returns the first key of$arrayif the array is not empty;NULL
otherwise.
范例
Basicarray_key_first()Usage
以上例程会输出:
string(1) "a"
注释
TipThere are several ways to provide this functionality for versions prior to PHP 7.3.0. It is possible to usearray_keys(), but that may be rather inefficient. It is also possible to usereset()andkey(), but that may change the internal array pointer. An efficient solution, which does not change the internal array pointer, written as polyfill:
参见
array_key_last()
Gets the last key of an arrayreset()
将数组的内部指针指向第一个单元
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!