Explanation of array variables of PHP Data types

Source: Internet
Author: User
Arrays in PHP are actually an ordered graph, which is a type that maps values to keys. An array is actually processing a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multi-dimensional array.

Arrays in PHP are actually an ordered graph, which is a type that maps values to keys. An array is actually processing a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multi-dimensional array. the elements in an array can be Integer or String. The variable type under the array in PHP does not affect the array. the array type has only one type, but can contain both the subscript of the integer type and the string type.
The syntax structure of the array is as follows:
Array ([key1 =>] value1
, [Key2 =>] value2 ,...
)
// Here, key1 and key2 can enable Integer or String
// While value can be any value, including string, integer, floating point, Boolean, or array object


To create an array, you can use the array () syntax structure. it accepts a certain number of key => value parameter pairs separated by commas. See Program 2-6.

Program 2-6 constructs a new array
$ Arr = array ("book" => "php", 8 => true );
Echo $ arr ["book"]; // Print the output result as php
Echo $ arr [8]; // Print the output result as 1.
?>

The key value of the array can be Integer or String.

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.