php遍历输出数组的方法
来源:程序员人生 发布时间:2014-02-05 14:07:39 阅读次数:2207次
php遍历输出数组的方法
实例一:
- <html>
- <head>
- <title>Foreach Demo</title>
- </head>
- <body>
- <?
- $list = array("A", "B", "C", "D", "E");
- print "<ul>n";
- foreach ($list as $value){
- print " <li>$value</li>n";
- }
- print "</ul>n";
- ?>
- </body>
- </html>
实例二
- <?
- $letters[0] = 'A';
- $letters[1] = 'B';
- $letters[3] = 'D';
- $letters[2] = 'C';
-
- foreach ($letters as $letter) {
- print $letter;
- }
- ?>
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠