Implementing the ideal idiom PHP array creation, invocation, and update implementation code

Source: Internet
Author: User
Copy CodeThe code is as follows:


$array = Array ("Key1" = "Simon", 2 = "Elaine"); Creation of arrays
echo $array ["Key1"]; Output Simon
Echo $array [2]; Output Elaine
?>


Copy the Code code as follows:


$array = Array ("key1" = = Array (0 = 1, 1 =, 2 = 100),
"Key2" = = Array (0 = 5, 1 =, 2 = 125));
echo $array ["Key1"][0]; Output 1
echo $array ["Key1"][1]; Output 10
echo $array ["Key1"][2]; Output 100
echo $array ["Key2"][0]; Output 5
echo $array ["Key2"][1]; Output 25
echo $array ["Key2"][2]; Output 125
?>


Copy the Code code as follows:


$array = Array ("key1" = = Array (0 = 1, 1 =, 2 = 100),//define Array
"Key2" = = Array (0 = 5, 1 =, 2 = 125));
Print_r ($array); Output array
?>


Copy the Code code as follows:


$array = Array ("A", "B", "C"); Defining arrays
Print_r ($array); Output array
?>


Copy the Code code as follows:


$array = Array ("A", "B", "C"); Defining arrays
$array [0] = "Simon"; Modifying an array element
Print_r ($array); Output array
?>

The above describes the realization of the ideal idiom PHP array creation, invocation and update implementation code, including the realization of the ideal idiom aspect of the content, I hope 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.