php foreach(仅显示其中的10个) [英] php foreach (show only 10 of them)
本文介绍了php foreach(仅显示其中的10个)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:
<?php
$files = glob("notes/last.*.*/table.php");
rsort($files);
foreach($files as $tables) {include $tables;}
?>
具有输出:
tables
tables
tables
从上到下,这将包括许多php文件.
This will include many php's files from starting from last to the older post.
我只想包含输出的前一个 10 .(即最后添加的10个)怎么做?
I want to include only the first 10 of the output. (that is the last 10 added) how to do it?
推荐答案
对此进行测试:
$i= 0;
foreach($files as $tables) {
$i++;
include $tables;
if($i == 10) break;
}
这篇关于php foreach(仅显示其中的10个)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文