PHP Arrays Array ()

Source: Internet
Author: User

Definition and usage

Array () creates arrays with keys and values. If the key is omitted when the array is created, an integer key is generated, starting from 0 by default and incrementing by 1.

Create an array with array () and use the = = to separate the keys and values.

To create an empty array, the parameter is not passed to array ():

$new = Array ();

Note: Array () is actually a language structure (language construct), which is typically used to define a direct array, but its usage is very similar to that of a function, so we'll also list it in the manual.

Grammar:

Parameters Describe
Key Optional. The specified key, type is numeric or string. If not set, the key of the integer type is generated.
Value Necessary. Specified value.

Example 1

Output:

Array (  [A] = AA  [b] = BB  [c] = CC)
Example 2

Output:

Array (  [0] = AA  [1] = BB  [2] = CC)

  

PHP Arrays Array ()

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.