The PHP array, plainly, is the associated data each array is in the form of index, value. Where the index defaults to the number starting with 0. When you do not specify an index, PHP automatically generates the index starting at 0. When you specify an index, PHP starts with the next integer that you specify to index the largest positive integer. If you specify a decimal number, PHP takes the integer part as the index.
In addition, some of the other small things in the array:
Array () can declare an empty array;
array[] = $value Append a data when an array exists, generate an array when the array is not saved, and append the data.
array[$index] = $value Append or modify a data when an array exists, generate an array when the array is not saved, and append the data.
Look at the following code:
Copy Code code as follows:
Declaring an array
$test = Array ();
Append Data
$test 01[] = "a"; Array (0 => "a");
Append a data with the index "a" and the data to "B"
$test 01["a"] = "B"; Array (0 => "a", "a" => "B");
Modify data with index 0
$test 01[0] = "C"; Array (0 => "C", "a" => "B");
Another way to declare a method
$test = Array ("A", "B", "C"); Array (0 => "a", 1 => "B", 2 => "C");
Although the data for a string index is declared, the default index still starts at 0
$test = Array ("A" => "a", "B", "C"); Array ("A" => "a", 0 => "B", 1 => "C");
The largest index in the declaration is 2, although the most recent index is 0, but the default index starts at 3
$test = Array (2 => "a", 0=> "B", "C"); Array (2 => "A", 0 => "B", 3 => "C");
Declaring a decimal index takes its integral part; When you specify an index, you modify the previously declared value
$test = Array ("A", 2.7=> "B", 0=> "C"); Array (0 => "C", 2 => "B");
Although a negative index is declared, the default index starts at 0
$test + = Array ( -2 => "A", "B", "C"); Array ( -2 => "A", 1 => "B", 2 => "C");
Definition of multidimensional arrays
$test modified = Array ($test, $test, $test 03);
It then introduces some of the fill functions of the array, which can be found in the manual, so it's just a simple introduction.
Range ($n, $m); Specifies the range of values. An array array (2,3,4) is generated as range (2,4).
Count ($array); Gets the size of the array.
Array_pad ($array, $length, $value); Returns an array of length $length, where the original insufficient array complement is $value and sufficient length to return the original array.