PHP 数组,数组索引是否区分大小写? [英] PHP array, Are array indexes case sensitive?

查看:26
本文介绍了PHP 数组,数组索引是否区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我还不知道这是否是一个问题,但想开始考虑.

I don't know if this is a problem yet but wanted to start thinking about it.

问题:

"PHP 数组索引是否区分大小写"?

示例:

$a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse","A"=>"Dog","B"=>"Cat","C"=>"Horse");
print_r($a);

结果:

Array ( [a] => Dog [b] => Cat [c] => Horse [A] => Dog [B] => Cat [C] => Horse ) 

我已经运行了几个例子,这似乎是正确的,只是想确保我正确地看到了这一点.

I've run a couple of examples and this seems to hold true, just wanted to make sure that I'm seeing this correctly.

推荐答案

是的.它们区分大小写.

Yes. They are case sensitive.

PHP 数组索引在您的示例中充当 哈希表.大写字母A"和小写字母a"具有不同的哈希值,因此它们将是不同的索引.

PHP array indexes act as hash tables in your example. A capital letter "A" and a lowercase letter "a" have different hash values, therefore they will be different indexes.

这篇关于PHP 数组,数组索引是否区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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