My understanding of the PHP array

Source: Internet
Author: User

Main references:

1. PHP Official manual: http://php.net/manual/zh/language.types.array.php

Basic meaning:

The array in PHP is actually an ordered map. A map is a type that associates values to the keys . This type is optimized in many ways, so it can be used as a real array, or as a list (vector), a hash (an implementation of a mapping), a dictionary, a collection, a stack, a queue, and more possibilities. Because the value of an array element can also be another array, the tree structure and the multidimensional array are also allowed.

TIP: An array can be a two-dimensional array, or a three-dimensional array. Please read the Baidu Encyclopedia: array: Http://baike.baidu.com/view/209670.htm?fr=aladdin

Basic syntax:

Defines an array of arrays ()

You can use the array () language structure to create a new array. It can contain any number of pairs of key=>value, but the key=>value is separated by a "," (comma).

The structure is like this:

Index array:

1 <? PHP 2 $myArray Array (' mother ', ' father ', ' sister ', ' brother '); 3 Print_r ($myArray); 4 ?>

Associate Array:

1 <? PHP 2 $myArray Array (' Mom ' = ' mother ', ' papa ' = ' father ', ' sister ' = ' sister ', ' elder brother ' = ' brother '); 3 Print_r ($myArray); 4 ?>

You can even mix the two (in fact PHP itself does not differentiate between the index array and the associate array):

1 <? PHP 2 $myArray Array (' Mom ' = ' mother ', ' papa ' = ' father ', ' sister ', ' brother '); 3 Print_r ($myArray); 4 ?>

Just power outage, all efforts are not saved, OK, let me hurt heart reply, and then start to write it ~ ~

My understanding of the PHP 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.