Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Are there only indexed arrays in php?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge of this article "is there only an index array in php", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "php is not only an index array" article.

Php has not only indexed arrays, but also concatenated arrays. PHP arrays can be divided into two types: 1, an array with numbers as its key name, that is, an indexed array; and 2, an array with a string or a mixture of strings and numbers as its key name, namely an associative array. If the key name is a string, wrap the key name with a delimiter (single or double quotation marks).

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php has not only indexed arrays, but also concatenated arrays.

Each entity in the array contains two items, a key (key) and a value (value). The corresponding array elements can be obtained by key values, which can be numeric keys or associated keys. If a variable is a container for a single value, then an array is a container for multiple values.

An array can store different types of data and is a compound data type. The data structure is shown in the following figure:

In the PHP array, no matter what type of key name there is, there will be a value corresponding to it, that is, a key / value pair. Depending on the array key name data type, we can divide the PHP array into two types:

An array with a number as its key name, namely an indexed array (Indexed Array)

An array with a string or a mixture of strings and numbers as a key name, that is, an associative array (Associative Array).

1) indexed array

The subscript (key name) of an indexed array consists of numbers. By default, starting from 0, each number corresponds to the position of an array element in the array, which does not need to be specified. PHP automatically assigns an integer value to the key name of the indexed array, and then increments automatically from this value.

2) associative array

The subscript (key name) of an associative array consists of a mixture of numeric values and strings, and if an array has a key name that is not a number, then the array is an associative array.

If the key name is a string, wrap the key name with a delimiter-single quotation mark''or double quotation mark "".

Note: the key name cannot be NULL.

The above is about the content of this article, "is there only index array in php?" I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report