There are several kinds of arrays in php
Xiaobian to share with you a few kinds of arrays in php, I believe most people do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
In php, an array is a collection of data that organizes a series of data into an operational whole. PHP arrays can be divided into three types: 1, numerical index array;2, associative array;3, multidimensional array.
Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer
What is an array?
An array is a collection of data that organizes a series of data to form an operational whole. Arrays in PHP are complex, but more flexible than arrays in many other high-level languages.
An array is an ordered set of variables where each value is called an element. Each element is distinguished by a special identifier called a key (also called a subscript).
Each entity in the array contains two items, a key and a value. Array elements can be retrieved by key values, either numeric or associative. If a variable is a container for storing a single value, then an array is a container for storing multiple values.
PHP arrays are more flexible than arrays in other high-level languages, supporting not only indexed arrays with numbers as keys, but associative arrays with strings or strings and numbers as keys. In other high-level languages, such as Java or C++, arrays only support numeric indexed arrays.
There are two ways to declare arrays in PHP:
Array elements can be declared directly by assigning values to them;
Declare an array using the array() function.
$array variable name [subscript] = value;$array variable name = array(key1 => value1, key2 => value2,..., keyN => valueN);
What are the types of arrays?
PHP arrays fall into three categories
Numeric index array:
An index array stores an organized series of single or multiple values, each of which can be accessed by using an unsigned integer value.
associative array:
An associative array is an array with a special indexing method. It can be indexed not only by integers, but also by strings or other types of values (other than NULL).
Multidimensional array:
The concept of a data structure, an array of more than two-dimensional arrays, an array that is neither linear nor planar, becomes a multidimensional array.
The above is "php array there are several" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!