PHP multidimensional array php Getting started learning Knowledge Point five several basic operations on PHP arrays

Source: Internet
Author: User
Tags array definition
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.