在PHP中,foreach不能大写
php:
<?php
//数组
$nav_list = [
'xiaomi'=>[
'chinese'=>'虾米',
'product_name'=>'虾米1',
'product_price'=>'1111',
'thubm'=>'https://i1.mifile.cn/f/i/g/2015/cn-index/qingchun-320.png',
],
'hongmi'=>[
'chinese'=>'红米',
'product_name'=>'红米1',
'product_price'=>'1222',
'thubm'=>'https://i1.mifile.cn/f/i/g/2015/cn-index/666320.png',
],
];
// 获取小米
// echo $nav_list["xiaomi"];
// 获取:https://i1.mifile.cn/f/i/g/2015/cn-index/qingchun-320.png
//
// $thubm = $nav_list["xiaomi"]["thubm"];
// echo "<img src='".$thubm."'/>"; //array
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<table>
<tr>
<th>商品类型</th>
<th>商品名称</th>
<th>商品价格</th>
<th>商品图片</th>
</tr>
<?php
// foreach遍历
foreach ($nav_list as $value) {
echo "<tr>
<td>{$value['chinese']}</td>
<td>{$value['product_name']}</td>
<td>{$value['product_price']}</td>
<td><img src='".$value['thubm']."'/></td>
</tr>";
}
?>
</table>
</body>
</html>
效果图: