1. Array definition:
[0]: The subscript that represents the array, or the keyword $arr[0]: Represents an element of an array $arr[0] =1:1 represents the value of an array $arr: The name of the array
Example 1,
'; The function count calculates the number of elements//traversal array for ($i =0; $i
';}? >
Example 2,
$val) { echo $key. ' = '. $val. '
';}
Result: logo= Beijing pwm=123123=abc
Note: 1,//********** Special instructions
"Logo", 45, 70,); Without defining the following table for the array, PHP will automatically use the largest number as the first subscript, followed by the element subscript automatically added 1//access to the value of the array of the logo we can write this//$arr [5] = "yes"; The value of the element is replaced by the Echo $arr [5]. '
'; Echo $arr [7];//by bbs.it-home.org
2.//Use decimal as key,php system to automatically truncate fractional parts
"PPP" =>234,12.7=> "World");p Rint_r ($a);
Result: Array ([ABC] = [PPP] = 234 [[+]] = world)
3. Use True to false null as keyword (subscript)
'; echo $a [null]. '
'; $a [22.6]=133; Use decimals as the key,php system to automatically truncate the fractional part//use Print_r to output an array to display an array of cases print_r ($a); Echo '
';//use Var_dump to display the information of the array in more detail var_dump ($a);
Effect: Hahaa China Array ([1] = what [0] = hahaa [] = [China] = 133) Array (4) {[1]=> string (4) "What" [0]=> ; String (5) "Hahaa" [""]=> string (6) "China" [22]=> Int (133)}
4, the PHP array can dynamically grow automatically
5. Several important functions in the array
'; Number of elements of the statistic function echo is_array ($a). '
'; Determines whether an array is print_r ($a); Echo '
'; Var_dump ($a); Display array Information $b= "1 2 3 ' One ', '" Three ' "; Echo '
-------------------------';p rint_r (Explode ("", $b)) $b =array (); Echo count ($b);? >Thank you for your attention to the PHP introductory tutorial, this series of basic PHP tutorial will help PHP novice friends, quickly master the language of PHP programming. The programmer's home will continue to introduce PHP-related tutorials For everyone, I wish you all the progress of learning!