$count = 0;
foreach ($records as $record) {
print $record;
$count++;
if ($count == 5) break;
}
PHP - Limit Array Results
-
This snipplet assumes you have all your records in an array If there id a way to get records one by one you’d better off with that for not hitting memory limits of php Which means fetching rows instead of fetching all result from db or reading files line by line
-
Thanks..exactly what I was looking for to limit the number of fetched result from db..used it to limit features items in opencart.