1. array definition:
[0]: represents the subscript of the array, or the keyword $ arr [0]: represents an element of the array $ arr [0] = represents the value of the array $ arr: array name
Example 1,
'; // Function count calculates the number of elements // traverses the array for ($ I = 0; $ I
';}?>
Example 2,
$ Val) {echo $ key. '='. $ val .'
';}
Result: logo = Beijing pwm = 123123 = abc
Note: 1. // *********** special instructions
"Logo",); // if the following table is not defined for the array, PHP will automatically use the largest number above as the first subscript, the following element subscript automatically adds 1 // The value of accessing the logo array. we can write this // $ arr [5] = "yes "; the element value echo $ arr [5] is replaced.'
'; Echo $ arr [7]; // by bbs.it-home.org
2. // use decimals as the key. the PHP system automatically truncates the fractional part.
12,'ppp'=>234,12.7=>"world");print_r($a);
Result: Array ([abc] => 12 [ppp] => 234 [12] => world)
3. use true false null as the keyword (subscript)
'; Echo $ a [null].'
'; $ A [22.6] = 133; // use a decimal number as the key, PHP automatically truncates the fractional part. // outputs the array using print_r to display the array. print_r ($ a); echo'
'; // Use var_dump to display the array information in more detail var_dump ($ );
Result: hahaa Chinese Array ([1] => what [0] => hahaa [] => China [22] => 133) array (4) {[1] => string (4) "what" [0] => string (5) "hahahaa" [""] => string (6) "China" [22] => int (133 )}
4. PHP array can automatically grow
5. several important functions in the array
'; // Count the number of elements in the function echo is_array ($ ).'
'; // Determine whether it is an array print_r ($ a); echo'
'; Var_dump ($ a); // Display array information $ B = "1 2 3 'one' two' 'Three'"; echo'
------------------------- '; Print_r (explode ("", $ B); $ B = array (); echo count ($ B);?>
Thanks for your attention to the php getting started tutorial. this series of basic php tutorials will help new php beginners to quickly master the php programming language. The programmer's home will continue to provide php tutorials for you and wish you a better learning experience!