Php Array Overview, classification, and declaration code demonstration. Copy the code as follows :? Php ***** Array Overview 1. array nature: managing and operating a group of variables, batch processing 2. arrays are composite types 3. arrays can store any length
The code is as follows:
/**
** An Array Overview
1. the essence of arrays: managing and operating a group of variables, batch processing
2. arrays are composite types.
3. data of any length can be stored in the array. You can also store any type of data.
4. arrays can complete the functions of data structures in other languages (linked list, queue, stack, and collection class)
**
II. array classification
An array contains multiple units (elements)
Each element is composed of the subscript [key] and value.
When accessing an element separately, the element is accessed through the subscript [key ].
1. one-dimensional array, two-dimensional array, three-dimensional array ..... Multi-dimensional array
(An array contains other arrays)
2. php has two types of arrays
Index array: Index of sequential integers.
Associated array: the subscript is a string as an index.
Only these two types of subscript (integer, string)
*
3. Multiple array declaration methods
1 directly assign values to array elements
If the index subscript is not given, the index starts from 0.
If the index subscript is given, the next one will increase by 1 from the maximum.
If the subscript appears next to it, if it is a value assignment, it is to re-assign the value to the previous element.
D. when the hybrid declaration is made, the index and association do not affect each other (the Declaration of the index subject is not affected)
2. use the array () function
A is an index array by default.
B. If you create a subscript for the associated array and index array, use the key => value
C. use commas (,) to separate multiple members;
3. use other function declarations
File ();
*
*
*
*
**/
Echo $ arr [5]
// Index the array
$ User [] = 1;
$ User [9] = "James"
$ User [0] = 10;
$ User [3] = "nan ";
$ Info = array (
"$ User" = array (
// $ User [0]
Array ("1", "Zhang San", 10, "nan "),
// $ User [1]
Array ("2", "lisi", 10, "nan "),
// $ User [2]
Array ("3", "wangwu", 10, "nan "),
),
"$ Score" = array (
// $ User [0]
Array ("1", "Zhang San", 10, "nan "),
// $ User [1]
Array ("2", "lisi", 10, "nan "),
// $ User [2]
Array ("3", "wangwu", 10, "nan "),
),
"$ Connect" = array (
// $ User [0]
Array ("1", "Zhang San", 10, "nan "),
// $ User [1]
Array ("2", "lisi", 10, "nan "),
// $ User [2]
Array ("3", "wangwu", 10, "nan "),
),
};
$ User [] [] = 1;
$ User [] [] = 1;
$ User [] [] = 1;
$ User [] [] = 1;
$ User [] [] = 1;
?>
The http://www.bkjia.com/PHPjc/326581.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326581.htmlTechArticle code is as follows :? Php/***** Array Overview 1. the essence of arrays: managing and operating a group of variables, batch processing 2. array is composite type 3. the array can store any length...