Android Programmers Learn PHP development (19)-Arrays (1) Basic concepts and definitions of the way-phpstorm

Source: Internet
Author: User
Tags learn php
PHP arrays are much more powerful than arrays of other languages, let's look at the basic concepts of arrays and how they are defined:




<?php/** * Array * Direct Assignment declaration array, as follows: * $arr = Array ("One" = "111111", "one" = "222222");    * One, two is key (key name), 111111, 222222 is the value (values, also called key value)/echo "----------Index array: Subscript is an integer----------<br>";    $arr [0] = 1;    $arr [1] = 2;    $arr [2] = 3; Print_r ($arr);    Printing results: Array ([0] = 1 [1] = 2 [2] + 3) echo "<br>";    echo "----------Associative array: subscript is string----------<br>";    $arr 1[' one '] = 1;    $arr 1[' "] = 2;    $arr 1[' three '] = 3; Print_r ($arr 1);    Print Result: Array ([one] = 1 [One] = 2 [three] + 3) echo "<br>";    echo "----------array Demo----------<br>";    $arr 2 = $arr + $arr 1;    Print_r ($arr 2);    echo "<br>";    echo "----------array Demo 2----------<br>";    $arr 3[] = 1;    $arr 3[] = 2;    $arr 3[] = 3;    $arr 3[] = 4;    Print_r ($arr 3);    echo "<br>"; /** * <pre> label function results formatted output, that is, printed by prototype.     It's more convenient to read.     * echo ' <pre> ';     * Print_r ($arr); * echo ' &LT;/PRE> ';    */echo "----------array Demo 3----------<br>";    $arr 4 = array ();    for ($i =0; $i <10; $i + +) {$arr 4[] = $i * $i;    } echo ' <pre> ';    Print_r ($arr 4);    Echo ' </pre> '; /* Print Result: Array ([0] = 0 [1] = 1 [2] = 4 [3] = 9 [     4] [+] [5] = [6] = [7] = [8] = [9] = 81)    */echo "----------array Demo 4----------<br>";    $arr 5 = array (); for ($i =0; $i <10; $i + +) {//echo $i. "        <br> ";        if ($i = = 4) {$arr 5[' andy Lau '] = "Aubagne";        } if ($i = = 7) {$arr 5[-100] = 6666;    } $arr 5[] = $i * $i;    } echo ' <pre> ';    Print_r ($arr 5);    Echo ' </pre> '; /* Print Result: Array ([0] = 0 [1] = 1 [2] = 4 [3] + 9 [andy Lau] = Aubagne [4] =&Gt [5] [+] [6] = [ -100] = [7] = 6666 [8] =&G T [9] = 81) *//** * Following are several ways to define arrays: */echo "----------array Demo 5----------<b    R> ";    $arr 6 = array (1,2,3,4,5,6);    $arr 7 = Array ("One", "one", "three");    $arr 8 = Array (0=> "AAA",1=> "BBB",2=> "CCC");    $arr 9 = Array ("AAA",6=> "BBB", "CCC"); $arr = Array ("name" = "Wang", "Age" =>20);

The above is the Android programmer to learn PHP development (19)-Array (1) Basic concepts and definitions of-phpstorm content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!

  • 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.