Ec (2); in the php tutorial, we commonly use two methods to traverse data. We use for and foreach for operations. The former is to know the Data Length, the latter may not know the data length. The following is an example. & Lt ;? $ Arrayarray (1, 2, 3, 4, 5, www.111cn.net, www.111cn.net); for ($ i0; $ I & lt; count ($ array); $ I ++) {& nbsp; e script ec (2); script
In the php tutorial, we commonly use two methods to traverse data, namely for and foreach. The former is to know the data length, and the latter can not know the Data Length, the following is an example.
$ Array = array (1, 2, 3, 4, 5, 'www .111cn.net ', 'www .111cn.net ');
For ($ I = 0; $ I
{
Echo $ array [$ I].'
';
}
The output result is as follows:
1
2
3
4
5
Www.111cn.net
Www.111cn.net
Foreach ($ array as $ v => $ vv)
{
Echo $ vv .'
';
}
The output result is as follows:
1
2
3
4
5
Www.111cn.net
Www.111cn.net
?>
The two types of output results are identical, so we will not talk about traversing multi-dimensional data. It is more convenient to use foreach for multi-dimensional data.
This site original tutorial, reproduced must be noted from the http://www.111cn.net/phper/php.html or study