Php array creation, calling, and updating implementation code _ PHP Tutorial

Source: Internet
Author: User
Php array creation, calling, and updating implementation code. Copy the code as follows :? Php $ arrayarray (key1Simon, 2 Elaine); echo $ array [key1] for array creation; output Simonecho $ array [2]; output Elaine? Copy code generation The code is as follows:


$ Array = array ("key1" => "Simon", 2 => "Elaine"); // create an array
Echo $ array ["key1"]; // output Simon
Echo $ array [2]; // output Eline
?>



The code is as follows:


$ Array = array ("key1" => arrays (0 => 1, 1 => 10, 2 => 100 ),
"Key2" => array (0 => 5, 1 => 25, 2 => 125 ));
Echo $ array ["key1"] [0]; // output 1
Echo $ array ["key1"] [1]; // output 10
Echo $ array ["key1"] [2]; // 100 output
Echo $ array ["key2"] [0]; // output 5
Echo $ array ["key2"] [1]; // output 25
Echo $ array ["key2"] [2]; // output 125
?>



The code is as follows:


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



The code is as follows:


$ Array = array ("a", "B", "c"); // defines an array
Print_r ($ array); // output array
?>



The code is as follows:


$ Array = array ("a", "B", "c"); // defines an array
$ Array [0] = "Simon"; // modify the array element
Print_r ($ array); // output array
?>

The http://www.bkjia.com/PHPjc/319944.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319944.htmlTechArticle code is as follows :? Php $ array = array ("key1" = "Simon", 2 = "Elaine"); // create an array echo $ array ["key1"]; // output the Simon echo $ array [2]; // output the elasticity? Generation...

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.