An array in PHP is actually an ordered graph, a type that maps values to keys. An array is actually a series of numbers and strings that are processed as a unit. Arrays can be two-dimensional, three-dimensional or multi-dimensional arrays, and the elements in them are also free and can be Integer or String. The variable type of array subscript in PHP will not affect the array. There is only one type of array, but it can contain both integer and string subscripts.
The syntax structure of the array is as follows:
array([key1=>]value1
,[key2=>]value2,...
)
//Among them, key1 and key2 can be Integer or String
// The value can be any value, including string, integer, floating point, Boolean or array object. To create a new array, you can use the array() syntax structure, which accepts a certain number of key= separated by commas. >value parameter pair. As shown in program 2-6.
Program 2-6 Construct a new array
$arr=array("book"=>"php",8=>true);
echo $arr["book"]; / /The printout result is php
echo $arr[8]; //The printout result is 1
?>
You can see that the key value of the array can be Integer or String.
The above is the detailed explanation of array variables of PHP data types. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!