PHP Arraysis actually an ordered map.
PHP ArraysA map is a type that associates values to the keys. This type is optimized in many ways, so it can be used as a real array, or as a list (vector), a hash (an implementation of a mapping), a dictionary, a collection, a stack, a queue, and more possibilities. Because
PHP ArraysThe value of the element can also be another
Array, the tree structure and multidimensional arrays are also allowed.
In general, the methods are defined as follows:
Method One:
$a =array (' A ', ' B ', ' C ');
The results of the operation are as follows.
Array
(
[0]=>a
[1]=>b
[2]=>c
[3]=>simon
)
Method Two:
$a =array (KEY1=>VALUE1,KEY2=>VALUE2,KEY3=>VALUE3);
Method Three:
$a [key1]=value1; $a [key2]=value2;
Method Four: Define an array by means of brackets []
PHP version 5.4 can be written later, the new array shorthand syntax.
PHP version 5.3 and previous versions do not accept this writing ...
$data = [' start_time ' = ' 123 ', ' end_time ' = ' 456 '];
Grammar
Defines an array of arrays ()
You can use the array () language structure to create a new array. It accepts any number of key (key) = = VALUES (value) pairs separated by commas.
Array ( key = value, ... ) Key (Key) is an integer or string string//value (value) can be any type of value
The comma after the last array element can be omitted. Typically used in a single-line array definition, such as a common array (1, 2) instead of an array (1, 2,). The last comma is usually reserved for multi-line array definitions, which makes it easier to add a new cell.
You can use the short array definition syntax since 5.4 to replace array () with [].
PHP arrays are simple and convenient to use, the same simple and convenient call, suitable for large and medium-sized data storage and call
Related recommendations:
Several ways to delete a specified value element in a PHP array
PHP array substitution function array_replace ()
Analysis of path method for array representation of PHP array to string