Home > Backend Development > PHP Problem > Are PHP array keys case sensitive?

Are PHP array keys case sensitive?

青灯夜游
Release: 2023-02-26 13:24:02
Original
3736 people have browsed it

An array is a special variable that can store multiple values ​​in a single variable. PHP array, as the name suggests, is an array in PHP. Its characteristic is to map values ​​to the type of keys. Unlike other languages, the keys of arrays in PHP can be strings, and the values ​​can be of any type.

Are PHP array keys case sensitive?

In PHP, there are three types of arrays:

● Numeric array - an array with a numeric ID key

● Association Array - an array with specified keys, each key is associated with a value

● Multidimensional array - an array containing one or more arrays

Then PHP array keys are case-sensitive No?

Array index (key name) is case-sensitive

<?php
$arr = array(&#39;one&#39;=>&#39;first&#39;);
echo $arr[&#39;one&#39;];    //输出&#39;first&#39;
echo $arr[&#39;One&#39;];    //无输出并报错
echo $Arr[&#39;one&#39;];    //上面讲过,变量名区分大小写,所以无输出并报错
?
Copy after login

For more PHP related knowledge, please visit PHP Chinese website!

The above is the detailed content of Are PHP array keys case sensitive?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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