This is an example of php about arrays. It briefly describes the basic use of arrays. Annotations are added in the example.
Copy codeThe Code is as follows:
<? Php
// Define a String Array
$ Fruit = array (\ "apple \", \ "orange \");
// Reference the array value
$ Fruit [0]; // indicates the value of apple
$ Fruit [1]; // indicates the value of orange.
// It is worth noting that the index of the array starts from 0. Anyone who has learned c and java knows it.
// Define a numeric Array
$ Number = array (, 5); // The value of the referenced array is the same as that
// Define a conforming Array
$ Mix = array (1, \ "example \", \ "hello \", 2.5); // The value of the referenced array is the same as that
// You can also use the key-value method to define an array.
$ Ex = array (\ "a \" => \ "fruit \", \ "B \" => \ "Car \");
// You can reference it like this
$ Ex [\ "a \"]; // the corresponding value is fruit.
$ Ex [\ "B \"]; // the corresponding value is the car
// You can also create an array with the key-value type.
?>