Arrays in PHP are actually an ordered graph, which is a type that maps values to keys. An array is actually processing a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multi-dimensional array.
Arrays in PHP are actually an ordered graph, which is a type that maps values to keys. An array is actually processing a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multi-dimensional array. the elements in an array can be Integer or String. The variable type under the array in PHP does not affect the array. the array type has only one type, but can contain both the subscript of the integer type and the string type.
The syntax structure of the array is as follows:
Array ([key1 =>] value1
, [Key2 =>] value2 ,...
)
// Here, key1 and key2 can enable Integer or String
// While value can be any value, including string, integer, floating point, Boolean, or array object
To create an array, you can use the array () syntax structure. it accepts a certain number of key => value parameter pairs separated by commas. See Program 2-6.
Program 2-6 constructs a new array
$ Arr = array ("book" => "php", 8 => true );
Echo $ arr ["book"]; // Print the output result as php
Echo $ arr [8]; // Print the output result as 1.
?>
The key value of the array can be Integer or String.