Array
1. The subscript of an array is an integer value or a string type.
Eg1. The key of the indexed array is ___, and the key of the associative array is ___.
2. When the string is indexed, the quotation marks should be added. Constants or variables do not have to be quoted, otherwise they cannot be compiled.
In PHP, a string without quotation marks automatically generates a bare string, and PHP may define it later, but unfortunately your code has the same name, and the string is re-assigned.
EG2. Show All Errors
Error_reporting (E_all);
$arr = Array (' fruit ' = ' apple ', ' veggie ' = ' carrot ');
That's right
Print $arr [' fruit ']; Apple
Print $arr [' Veggie ']; Carrot
is not correct. This works but also throws a PHP error of
Level e_notice because of an undefined constant named fruit
//
Notice:use of undefined constant fruit-assumed ' fruit ' in ...
Print $arr [fruit]; Apple
Let's define a constant to demonstrate what's going on. We
Would assign value ' veggie ' to a constant named fruit.
Define (' fruit ', ' veggie ');
Notice the difference now
Print $arr [' fruit ']; Apple
Print $arr [fruit]; Carrot
The following is okay as it ' s inside a string. Constants is not
Looked for within strings so no e_notice error here
print "Hello $arr [fruit]"; Hello Apple
With one exception, braces surrounding arrays within strings
Allows constants to being looked for
Print "Hello {$arr [fruit]}"; Hello Carrot
Print "Hello {$arr [' Fruit ']}"; Hello Apple
This won't work, results in a parse error such as:
Parse error:parse error, expecting t_string ' or t_variable ' or t_num_string '
This is course applies to using autoglobals in strings as well
print "Hello $arr [' Fruit ']";
Print "Hello $_get[' foo ']";
Concatenation is another option
Print "Hello". $arr [' Fruit ']; Hello Apple
?>
3. Key-Value issues
$a [' color '] = ' red ';
$a [' taste '] = ' sweet ';
$a [' shape '] = ' round ';
$a [' name '] = ' apple ';
$a [] = 4; Key'll be 0
$b [] = ' a '; Key'll be 0
$b [] = ' B '; Key'll be 1
$b [] = ' C '; Key'll be 2
switching = Array (ten,//key = 0
5 = 6,
3 = 7,
' A ' = 4,
One,//key = 6 (maximum of integer-indices was 5)
' 8 ' = 2,//key = 8 (integer!)
' In the ' + ',//key = ' 02 '
0 = +//The value of would be overwritten by 12
);
$multi _array = Array ("Red",
"Green",
"Blue", "yellow" + = Array ("Apple", 9 = "pear", "banana", "orange" = = Array ("Dog", "Cat", "Iguana"));
?>
A $multi _array[' yellow ' [' apple '][0]
B $multi _array[' blue '][0][' orange '][1]
C $multi _array[3][3][2]
D $multi _array[' yellow ' [' orange '] [' cat ']
E. $multi _array[' yellow ' [' Orange '][1]
--------------------------------to be continued------
4.array_walk
5.var_dump
6.array_intersect
7.array_sum
8.array_count_values
9.array_flip
10.natsort
11.ksort (), Asort (), Krsort (), sort (), Usort ()
12.array_reverse ()
13.array_merge
14.reset
-------------------------------to be continued------
15.array_combine
16array_count_values
17.array_diff
18.array_filter
19.array_search
The above describes the PHP array php array summary one), including the contents of the PHP array, I hope to be interested in PHP tutorial friends helpful.