Detailed explanation of array variables of PHP data types

黄舟
Release: 2023-03-03 21:08:01
Original
1366 people have browsed it

An array in PHP is actually an ordered graph, a type that maps values ​​to keys. An array is actually a series of numbers and strings that are processed as a unit. Arrays can be two-dimensional, three-dimensional or multi-dimensional arrays, and the elements in them are also free and can be Integer or String. The variable type of array subscript in PHP will not affect the array. There is only one type of array, but it can contain both integer and string subscripts.
The syntax structure of the array is as follows:
array([key1=>]value1
,[key2=>]value2,...
)
//Among them, key1 and key2 can be Integer or String
// The 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 certain number of key= separated by commas. >value parameter pair. As shown in program 2-6.

Program 2-6 Construct a new array
$arr=array("book"=>"php",8=>true);

echo $arr["book"]; / /The printout result is php
echo $arr[8]; //The printout result is 1
?>

You can see that the key value of the array can be Integer or String.

The above is the detailed explanation of array variables of PHP data types. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!