PHP Learning Notes-Arrays (1), PHP Learning notes array
1-1 Array Definitions
1. What is an array?
An array is a set of elements of the same data type arranged in a certain order, that is, a variable of the same type is named with a name, and then the set of the variable is distinguished by a number, which is called the array name, and the number is called the subscript. Each variable that makes up an array is called the component of an array, also known as an element of an array, sometimes called a subscript variable.
The syntax is as follows:
PHP// set a variable to an empty array $arr=array(); >
1-2 Initialization of indexed arrays
PHP has two types of arrays: indexed arrays, associative arrays.
Indexes and associations two words are for the keys of an array.
An indexed array is an array of exponential groups whose keys are integers, and the integer order of the keys starts at 0, and so on.
PHP $num=array(+/-); Print_r ($num[0]);? >
Output results: 1
1-3 Indexed Array Assignment
3 different methods
PHP$arr[0]=1; // Method 1 $arr=array(' 0 ' =>1); // Method 2 $arr=array(1); // Method 3?>
1-4 Accessing array contents
PHP// from the array variable $arr, read the value of the key 0 $arrArray(--); $arr 0=$arr[0]; Echo $arr 0 ;? >
http://www.bkjia.com/PHPjc/975063.html www.bkjia.com true http://www.bkjia.com/PHPjc/975063.html techarticle PHP Learning Notes-Arrays (1), PHP Learning notes array 1-1 array definition 1. What is an array? The so-called array is the set of elements of the same data type arranged in a certain order, that is, the limited ...