<?php
// 与html混合使用循环
// for():
// html代码
// endfor;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
li{
width:234px;
height:340px;
border:#ccc solid 1px;
list-style:none;
text-align:center;
float:left;
}
</style>
</head>
<body>
<ul>
<?php for($i=0; $i<10; $i++): ?>
<li>
<img src="t1.jpg" width=160>
<p>小米手机5 高配版</p>
<p>3GB内存+64GB容量,玻璃版</p>
<p>¥2099</p>
</li>
<?php endfor; ?>
</ul>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title></title>
<style>
li{
width:222px;
height:444px;
border:1px solid red;
float:left;
list-style:none;
text-align:center;
padding:22px;
}
</style>
</head>
<body>
<ul><?php foreach($arr as $val ): ?>
<li>
<img src="<? = $val['img']?>">
<p><?php echo $val['name']?></p>
<p><del><? = $val['previous']?></del></p>
<b><?= $val['jump']?></b>
</li>
<?php endforeach;?>
</ul>
</body>
</html>
网友评论