Array variables for PHP data types

Source: Internet
Author: User
The array in PHP is actually an ordered graph, which is a type that maps values to keys. An array actually handles a series of numbers and strings as a unit. An array can be a two-dimensional, three-dimensional, or multidimensional array, where the elements are also free, either integer or String. The variable type of the array subscript in PHP is not affected by the array, only one type, but it can contain both integer and string subscripts.
The syntax structure of the array is as follows:
Array ([key1=>]value1
, [Key2=>]value2,...
)
Where Key1 and Key2 can make an integer or string
Value can be any value, including string, Integer, floating-point, Boolean, or array-object


To create a new array, you can use the array () syntax structure, which accepts a number of key=>value parameter pairs separated by commas. As shown in program 2-6.

Program 2-6 constructs a new array
<?php
$arr =array ("book" = "php", 8=>true);
echo $arr ["book"]; Print out the results for PHP
echo $arr [8]; The printout results in 1
?>

You can see the key value of the array key can be an integer or a string.

The above is the PHP data type array variable detailed 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.