Home > Backend Development > PHP Tutorial > PHP,如何判断一个array的key是自己填的还是自动生成的?

PHP,如何判断一个array的key是自己填的还是自动生成的?

WBOY
Release: 2016-06-06 20:13:24
Original
948 people have browsed it

我想区分开不同的array分别处理,区分靠key的值是(通过array_push)自动生成的index还是自己填的(string之类的)index

甚至是混合的key

这个问题已被关闭,原因:与 https://segmentfault.com/q/1010000004728170 重复提问

回复内容:

我想区分开不同的array分别处理,区分靠key的值是(通过array_push)自动生成的index还是自己填的(string之类的)index

甚至是混合的key

利用下array_keys()获取数组的全部键值或者key()获取当前指针指向的键值

具体看下官方文档吧,有示例
http://php.net/manual/en/function.array-...
http://php.net/manual/en/function.key.ph...

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template