Copy CodeThe code is as follows:
/*
* Simple array definition and access
*/
echo "simple array definition and access
";
echo "############################################################
";
$address =array (5);
$address [0]= "Fuzhou";
$address [1]= "Xiamen";
$address [2]= "Zhangzhou";
$address [3]= "Quanzhou";
$address [4]= "Ningde";
$address [5]= "Nanping";
$address [6]= "Longyan";
echo "I live in $address[1 now"
";
echo "############################################################
";
/*
* Array Traversal
*/
echo "Array traversal via for loop
";
echo "############################################################
";
for ($index =0; $index Print ("section in array". $index. " Area $address[$index] for
");
}
echo "############################################################
";
/*
* Array Initialization
*/
echo "Array initialization, and the date function to get the current month of the number, output the contents of the relevant array subscript
";
echo "############################################################
";
$arrM
Date_default_timezone_set ("UTC"); Set the default time zone
$m
echo "Array structure is";
Print_r ($arrMonth);
echo "is now". $month. " Month, his English is ". $arrMonth [$month-1]."
";
echo "############################################################
";
/*
* array initialization, and defining keys, and then accessing the array via key values
*/
echo "Array initialization, and define keys, and then access the array by key
";
echo "############################################################
";
$arrM
, "August" "=", "Sept" and "Septmber", "Oct" = "October", "Nov" = "November", "Dec" and "December"
);
echo "accesses an array through the English abbreviation". $arrMonth ["the"]. "
";
echo "############################################################
";
echo "Iterate through the array with foreach
";
echo "############################################################
";
foreach ($arrMonth as $key = = $value) {
echo "= key is $key, value is $value
";
}
echo "############################################################
";
/*
* Define multidimensional arrays
*/
echo "defines a two-dimensional array
";
$arrArea =array ("East" =>array ("Fujian", "Zhejiang"), "North China" =>array ("Beijing", "Tianjin"));
echo "East China =". $arrArea ["East China"][0]
?>
The above describes the PHP multidimensional array php Introductory learning knowledge Point Five on the PHP array of several basic operations, including the PHP multidimensional array of content, I hope that the PHP tutorial interested in a friend helpful.