The array in PHP is actually an ordered map. A 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 the value of an array element can also be another array, the tree structure and the multidimensional array are also allowed.
Role:
1, management and operation of a set of data, data can be any type, arbitrary length.
2, the array is generally composed of keys and values, through the array of subscript to operate.
3, the declaration of the array uses array ().
4. The subscript of the array starts from 0.
Classification:
1. Index array: Subscript is an integer index of the order (starting from 0)
2. Associative array: Subscript is a string index
<?php//Index Array Example $arr1 = Array ("Apple", "orange", "Cup"), $arr 2 = Array ("Ten", "J", "Q", "K", "A");//associative array example $ARR3 = Array ("One "=" "First", "second", "three" and "third"); $arr 4 = Array ("Apple" + "red", "orange" = "Yellow", " Grapes "=" purple ");//fast use of arrays, flexible definition, easy to use. $arr 5[]=1; $arr 5[]=3; $arr 5[]=6;?>
Array printing/viewing
<?php//How to view array echo "<pre>" Print_r ($arr 1);//prototype output, view array values and array structure, $arr 1 array variable name, you can change $arr2 or other already declared arrays echo "< ;/pre> "?>
This article from the "Golden Three" blog, declined to reprint!
Definition of arrays in PHP and examples of declarations