The array in PHP is actually an ordered graph, which is a type that maps values to keys. An array actually handles a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multidimensional array, where the elements are also free, either integer or String. The variable type of the array subscript in PHP is not affected by the array, only one type, but it can contain both integer and string subscripts.
The syntax structure of the array is as follows:
Array ([key1=>]value1
, [Key2=>]value2,...
)
Where Key1 and Key2 can make an integer or string
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 number of key=>value parameter pairs separated by commas. As shown in program 2-6.
Program 2-6 constructs a new array
<?php
$arr =array ("book" = "php", 8=>true);
echo $arr ["book"]; Print out the results for PHP
echo $arr [8]; The printout results in 1
?>
You can see the key value of the array key can be an integer or a string.
The above is the PHP data type array variable detailed content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!