For details about the syntax definition of the PHP array. After a long history of PHP development, many users are familiar with PHP. here I will share my personal understanding and discuss it with you. the PHP array is actually an ordered graph. The figure shows how val PHP has been developing for a long time. many users know PHP very well. here I will share my personal understanding and discuss it with you, the PHP array is actually an ordered graph. A graph is a type that maps values to keys.
This type has been optimized in many ways, so you can use it as a real array, or a list (vector), a hash (an implementation of a graph), a dictionary, set, stack, queue, and more possibilities. Because another PHP array can be used as the value, and the tree can be easily simulated. Interpreting these structures is beyond the scope of this manual, but you will find at least one example for each structure. For more information about these structures, we recommend that you refer to external works on this broad topic. Next we will introduce in detail the knowledge about PHP arrays.
PHP array syntax definition array ()
You can use the array () language structure to create an array. It accepts a certain number of key => value parameter pairs separated by commas.
- Array ([Key=>]
- Value
- ,...
- )
- // The key can be integer or string.
- // Value can be any value
-
- Php
- $Arr=Array("Foo" =>"Bar ",12=>True );
-
- Echo $ arr ["foo"]; // bar
- Echo $ arr [12]; // 1
- ?>
The key can be an integer or string. If the key name is an integer standard expression, it is interpreted as an integer (for example, "8" will be interpreted as 8, and "08" will be interpreted as "08 "). The variable type under the array in PHP does not affect the array. the array type has only one type. it can contain both the subscript of the integer type and the string type, and the value can be any value.
- php
- $arr=array("somearray"=>array(6=>5,13=>9,"a"=>42));
- echo$arr["somearray"][6];//5
- echo$arr["somearray"][13];//9
- echo$arr["somearray"]["a"];//42
- ?>
If no key name is specified for the given value, the current maximum integer index value is used, and the new key name is the value plus one. If the specified key name already has a value, the value will be overwritten.
- php
- //Thisarrayisthesameas...
- array(5=>43,32,56,"b"=>12);
-
- //...thisarray
- array(5=>43,6=>32,7=>56,"b"=>12);
- ?>
Bytes. The image is a type of val...