Array
There are generally 2 ways to initialize an array: One is to assign values to the elements in the array, and one is to initialize all the elements together.
The following is a brief description of 2 ways to initialize an array:
The first method:
$a ["Color"]= "red";
$a ["Taste"]= "sweet";
$a ["Shape"]= "round";
$a ["Name"]= "Apple";
$a [3]=4;
The second method:
$a =array (
"Color" => "red",
"Taste" => "sweet",
"Shape" => "Round",
"Name" => "Apple",
3=>4);
The effects of the two methods are the same, but the different methods of assigning values to the elements are different.
As an example, it is worth noting that the assignment of an element in an array begins with the second element.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Initialization Array </title>
<body>
<font size= "5" >
<?php
$monthName =array (1=> "January", "February", "March", "April", "may", "June", "July", "August", "September", "October" , "November", "December");
Print ("English" May "is <b> $monthName [5]</b>.<br>\n");
?>
</font>
</body>