Overview of PHP arrays and classification and Declaration code Demo _php Tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:
/**
* * An overview of an array
1. The nature of arrays: managing and manipulating a set of variables, batch processing
2. Arrays are composite types
3. You can store data of any length in the array. You can also store any type of data
4. Array can complete the function of other language data structure (list, queue, Stack, collection Class)
**
Two. Classification of arrays
Multiple cells are stored in an array (cells are called elements)
Each element consists of a subscript "key" and a value
When accessing elements individually, the elements are accessed through the subscript "key"
1. One-dimensional arrays, two-dimensional arrays, three-dimensional arrays ..... Multidimensional arrays
(An array of arrays, which is the existence of other arrays in the array)

There are two types of arrays in 2.php
Indexed array: The index of the ordinal integer that is the subscript "key"
Associative arrays: subscripts are strings as indexes
Subscript (integer, string) only these two types of
*
Three. Array declarations in multiple ways
1 assigning values directly to an array element
If index subscript is not given, it will be indexed starting from 0
If the index subscript is given, the next one will increase by 1 from the largest start.
If the preceding subscript appears, the assignment is to reassign the previous element
d Mixed Declaration When indexes and associations do not affect each other (does not affect the declaration of index subscript)
2 using the array () function

A default is an indexed array
B. If subscripts are used for associative arrays and indexed arrays, use the key = = value
Use "," split between multiple members of C;
3 using a different function declaration
File ();

*
*
*
*
**/

Echo $arr [5]

Indexed array
$user []=1;
$user [9]= "Zhang San"
$user [0]=10;
$user [3]= "Nan";
$info =array (
"$user" =array (
$user [0]
Array ("1", "Zhang San", Ten, "Nan"),
$user [1]
Array ("2", "Lisi", Ten, "Nan"),
$user [2]
Array ("3", "Wangwu", Ten, "Nan"),
),
"$score" =array (
$user [0]
Array ("1", "Zhang San", Ten, "Nan"),
$user [1]
Array ("2", "Lisi", Ten, "Nan"),
$user [2]
Array ("3", "Wangwu", Ten, "Nan"),
),

"$connect" =array (
$user [0]
Array ("1", "Zhang San", Ten, "Nan"),
$user [1]
Array ("2", "Lisi", Ten, "Nan"),
$user [2]
Array ("3", "Wangwu", Ten, "Nan"),
),
};

$user [][]=1;
$user [][]=1;
$user [][]=1;
$user [][]=1;
$user [][]=1;

?>

http://www.bkjia.com/PHPjc/326581.html www.bkjia.com true http://www.bkjia.com/PHPjc/326581.html techarticle Copy the code as follows: PHP/** * * An overview of an array 1. The essence of an array: managing and manipulating a set of variables, batching 2. An array is a compound type 3. An array can store any length of ...

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