Android programmers learn PHP development (19)-array (1) Basic concepts and definitions-PhpStorm

Source: Internet
Author: User
PHP arrays are much more powerful than arrays in other languages. let's take a look at the basic concepts of arrays and the definition of arrays: PHP arrays are much more powerful than arrays in other languages, next, let's take a look at the basic concepts of arrays and the definition of arrays:

 "111111", "two" => "222222"); * where one and two are key (key name), 111111 and 222222 are value (value, also called key value) */echo "---------- index array: the subscript is an integer ----------
"; $ Arr [0] = 1; $ arr [1] = 2; $ arr [2] = 3; print_r ($ arr); // print the result: array ([0] => 1 [1] => 2 [2] => 3) echo"
"; Echo" ---------- join array: subscript is a string ----------
"; $ Arr1 ['one'] = 1; $ arr1 ['two'] = 2; $ arr1 ['Three '] = 3; print_r ($ arr1 ); // print the result: Array ([one] => 1 [two] => 2 [three] => 3) echo"
"; Echo" ---------- array Demo ----------
"; $ Arr2 = $ arr + $ arr1; print_r ($ arr2); echo"
"; Echo" ---------- array Demo 2 ----------
"; $ Arr3 [] = 1; $ arr3 [] = 2; $ arr3 [] = 3; $ arr3 [] = 4; print_r ($ arr3); echo"
";/***
The result of the label function is formatted and output, that is, printed according to the prototype. It is easier to read. * Echo'
';     *     print_r($arr);     *     echo '
'; */Echo "---------- array Demo 3 ----------
"; $ Arr4 = array (); for ($ I = 0; $ I <10; $ I ++) {$ arr4 [] = $ I * $ I ;} echo'
';    print_r($arr4);    echo '
';/* Print the result: array ([0] => 0 [1] => 1 [2] => 4 [3] => 9 [4] => 16 [5] => 25 [6] => 36 [7] => 49 [8] => 64 [9] => 81) */echo "---------- array Demo 4 ----------
"; $ Arr5 = array (); for ($ I = 0; $ I <10; $ I ++) {// echo $ I ."
"; If ($ I = 4) {$ arr5 ['Andy Lau '] =" Obama ";} if ($ I = 7) {$ arr5 [-100] = 6666;} $ arr5 [] = $ I * $ I;} echo'
';    print_r($arr5);    echo '
';/* Print the result: array ([0] => 0 [1] => 1 [2] => 4 [3] => 9 [Andy Lau] => Ouba [4] => 16 [5] => 25 [6] => 36 [-100] => 6666 [7] => 49 [8] => 64 [9] => 81) * // ** The following are several ways to define an array: */echo "---------- array Demo 5 ----------
"; $ Arr6 = array (1, 2, 3, 4, 5, 6); $ arr7 = array (" one "," two "," three "); $ arr8 = array (0 => "aaa", 1 => "bbb", 2 => "ccc"); $ arr9 = array ("aaa ", 6 => "bbb", "ccc"); $ arr10 = array ("name" => "wang", "age" => 20 );

The above is the basic concepts and definitions of PHP Development (19)-array (1)-PhpStorm content for Android programmers. For more information, see PHP Chinese website (www.php1.cn )!

Related Article

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.