【发布时间】:2011-03-18 03:00:24
【问题描述】:
我正在开发自定义分页系统并遇到以下问题。当其中一个元素从集合中过滤出来时,最终数组的大小小于所需的大小。因此,我正在寻找一种解决方案来增加循环内的迭代次数,以始终获得由 50 个元素组成的数组。
$limit = 50; //Number of elements I want to fetch
for($x=0; $x<$limit; $x++){
if ($elementIsNotFiltered) {
//add element to $someArray;
}
else {
//increase the number of iterations, so even if some elements are filtered out,
//the size of $someArray will always be 50
}
}
感谢您的帮助。
【问题讨论】: