I have a foreach loop which loops through an array (simpleXML nodes). This array can have between 0 and several hundred items in it. I'd like to find a way to display the first 10 results and then have a link to display the next 10 and so on.
for instance, I currently have:
$i=0;
$limit=10;
foreach ($nodes as $node){
echo "here is the output: ".$node."<br>\n";
if (++$i >=$limit) break;
}
obviously, no matter how many items are in the $nodes array, it only displays the first 10. But I think I read that foreach loops reset the counter every time they run - so if I wanted to have a link that said: next 10 itmes
- I'm not sure how I would tell the the loop to start on index=10.
Am I even barking up the right tree here?