Php defines arrays and usage examples (php array definition method ). This is an example of php on the array. it briefly describes the basic use of the array. in the example, a comment is added to copy the code as follows :? Php defines a string array $ fruit. this is an example of the php array. it briefly describes the basic use of the array, and adds a comment in the example.
The code is as follows:
// 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.
?>
The pipeline code is as follows :? Php // define a string array $ fruit =...