1, PHP defines the format of the array
Array name =array ();
such as: $aa =array ();//This defines an array,
Then assign values to the elements:
$aa [0]= "9016"; $aa [1]= "9017"; $aa [2]= "9018";
2, the PHP output array method:
foreach ($aa as $val) {echo$val;}
You can also assign a value directly when you define an array
$aa =array (0=> "9016",1=> "9017";2=> "9018");
3, the PHP array can also be used to subscript the character, not necessarily the number.
$AA ["Name"]= "Joan"; $AA ["Num"]= "9018"; $aa ["Email"]= "[email protected]";
You can do that.
$aa =array ("name" = "Joan", "num" = "9018", "email" = "[email protected]");
The element of a one-dimensional array is also defined as an array, which is a two-dimensional
$aa =array (0=> "A1",1=> "A2"), $bb =array (0=> "B1",1=> "B2"), $cc =array (0=> $aa;1=> $bb);
At this point, $cc [0] is an array, $CC [1] is an array, $CC is a two-dimensional array.
Similarly, three-dimensional, four-dimensional arrays can continue to be defined.
4 , the elements of an array are not only numbers and strings, but can be objects of a class.
Original:
Http://3women.blog.sohu.com/135437525.html
Methods for defining arrays in PHP