只想让这个显示8个。不想全部显示。请帮写完整,谢谢
<?php if ($history){
foreach ($history as $val){
echo "<a href=?id=$val[0] class='urls'>".$val[3]."</a><br />"; }
}else{
echo "<br><p>暂无记录</p>";
}
?>
------解决方案--------------------foreach (array_slice($history, 0, 8) as $val)
------解决方案--------------------if ($history){
foreach (array_slice($history, 0, 8) as $val){
echo "<a href=?id=$val[0] class='urls'>".$val[3]."</a><br />";
}
}else{
echo "<br><p>暂无记录</p>";
}
------解决方案--------------------