PHP:数组的索引,元素,键,值之间有区别吗?......它们是一样的吗? [英] PHP: is there difference between Index, Element, Key, Value of an Array?... are they the same thing?

查看:211
本文介绍了PHP:数组的索引,元素,键,值之间有区别吗?......它们是一样的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当处理 PHP 数组时,我经常在这里使用以下术语:

When dealing with PHP arrays, I quite often here terms such as:

数组

数组 指数

数组 元素

数组 价值

中有人简单的术语解释了这些基本上的含义是什么?

Can someone, PLEASE , in simple terms explain what each of these basically means?

有什么不同吗?......他们都指的是同样的事情?

Is there any difference?... are they all referring to the same thing?

你在哪里使用哪个?什么时候?

Where do you use which? and when?

对于一些简单的用例示例的任何澄清都将受到高度赞赏。

Any clarification with some simple use case examples will be highly appreciated.

ie:在数组中,如:数组($ a,$ b,$ c,$ d => $ e)什么是什么?

i.e: in an array like: array($a,$b,$c,$d=>$e) What will be What?

提前致谢。

推荐答案

数组是元素的集合。< br>
每个元素都有关键&值。键可以是整数(索引)或字符串。

在你的情况下

An array is a collection of Elements.
Every element has key & value. Key can be a integer(index) or a string.
In you case

数组($ a,$ b ,$ c,$ d => $ e)

可以改写为

array(0 => $a, 1 => $b, 2 => $c, $d => $e);  

其中0,1,2,$ d是数组的键。

您可以将0,1,2分别作为$ a,$ b,$ c的索引,$ d是$ e的密钥。

Where 0, 1, 2, $d are the keys of the array.
You can refer 0, 1, 2 as a index for value $a,$b,$c respectively and $d is a key for $e.

这篇关于PHP:数组的索引,元素,键,值之间有区别吗?......它们是一样的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆