PHP – Limit Array Results

$count = 0;
foreach ($records as $record) {
print $record;
if ($count == 5) break;

2 thoughts on “PHP – Limit Array Results”

  1. 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

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.