首页 > 代码库 > foreach遍历 < 创建表 >练习题

foreach遍历 < 创建表 >练习题

 1 </head>
 2 
 3 <body>
 4 <table border="1" width="500" height="300"/>
 5 <tr>
 6     <th>Ids</th>
 7     <th>Name</th>
 8     <th>Price</th>
 9     <th>Source</th>
10     <th>Numbers</th>
11     <th>Image</th>
12 </tr>
13 <?php
14 $arr=array(
15     array("k001","苹果","2.4","烟台","100","image/0.gif"),
16     array("k002","菠萝","2.4","广东","100","image/1.gif"),
17     array("k003","橘子","2.4","福州","100","image/2.gif"),
18     array("k004","葡萄","2.4","新疆","100","image/3.gif"),
19          );
20          foreach($arr as $v)
21          {
22              echo"<tr>
23     <td>{$v[0]}</td>
24     <td>{$v[1]}</td>
25     <td>{$v[2]}</td>
26     <td>{$v[3]}</td>
27     <td>{$v[4]}</td>
28     <td>{$v[5]}</td>
29 </tr>";
30              }
31 ?>
32 
33 </table>
34 </body>
35 </html>
原图:
技术分享
效果图:
技术分享

 

 

foreach遍历 < 创建表 >练习题