I have a code that fetches and displays results using foreach function but problem is it returns a lot of results so page loading is very slow! Is there any way to break these results into pages like 1,2,3,4 & display only 10 results per page?
my code is
foreach ($results[1] as $url)
{
echo "<a href='$url'>$url</a> <br>";
$i++;
}
If the data is coming from a database, you should limit it there already with a
LIMITclause.If you have no control over the source of the data, you can use
array_slice()on$results[1]to get the section you want, based on the page-number and the number of items you want to display: