Home >Backend Development >PHP Tutorial > 只想让这个显示8个。不想全部显示。请帮写完整,多谢

只想让这个显示8个。不想全部显示。请帮写完整,多谢

WBOY
WBOYOriginal
2016-06-13 13:42:01785browse

只想让这个显示8个。不想全部显示。请帮写完整,谢谢
foreach ($history as $val){
echo "".$val[3]."
";

}
}else{
echo "

暂无记录

";
}
?>

------解决方案--------------------
foreach (array_slice($history, 0, 8) as $val)
------解决方案--------------------
if ($history){
foreach (array_slice($history, 0, 8) as $val){
echo "".$val[3]."
";
}
}else{
echo "

暂无记录

";
}
------解决方案--------------------
探讨

引用:
foreach (array_slice($history, 0, 8) as $val)

可以显示最新的8条数据吗?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn