Simplepie分页
问题描述:
我试图按照此处所述设置分页:http://simplepie.org/wiki/tutorial/how_to_do_item_paging,但它不起作用,因为在我的情况下,有一个if语句显示只有某些项目的标题,其中的类别定义为Apples简单的例子。任何人都知道用这个例子来做分页的方法吗?Simplepie分页
foreach ($feed->get_items() as $item):
if($item->get_category()->get_label() == 'Apples'){
echo $item->get_title();
}
endforeach;
答
1)将$ items分配给关联数组,而不是在标签匹配时直接使用“echo”。
2)使用计数()函数
3)使用array_splice通联阵列获取阵列的计数(),以获得仅项目所需的数目和偏移
array_splice($array,$start,$itemPerPage)
4)同总阵列数和$ itemPerPage可以使分页