Michan Posted December 9, 2007 Share Posted December 9, 2007 Hi all, Say I have an array of twenty results; how would I output, for example, results # 5 - 10 (for pagination)? Here is 1 - 5: $i = 0; foreach($topiclist as $key => $val) { echo $val.'<hr>'; if(++$i==5) { break; } } Many thanks in advance, - Mi Link to comment https://forums.phpfreaks.com/topic/80905-solved-controlling-amount-of-results-outputted-by-an-array/ Share on other sites More sharing options...
rab Posted December 9, 2007 Share Posted December 9, 2007 <?php $offset = (int)$_GET['page']; $size = 10; $topics = array_slice($topiclist, $offset, $size); foreach($topics as $key => $val) echo "$val<hr>"; ?> Try something like that. Link to comment https://forums.phpfreaks.com/topic/80905-solved-controlling-amount-of-results-outputted-by-an-array/#findComment-410427 Share on other sites More sharing options...
Michan Posted December 9, 2007 Author Share Posted December 9, 2007 Thanks, works perfectly Solved! Link to comment https://forums.phpfreaks.com/topic/80905-solved-controlling-amount-of-results-outputted-by-an-array/#findComment-410437 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.