Limit number of results for glob directory/folder listing
<p>How would I go about limiting the number of directory results/pdfs to, say 8, in the following code?</p>

<pre><code>$counter = 0; 
foreach (glob("/directory/*.pdf") as $path) { //configure path
    $docs[filectime($path)] = $path;
} 
krsort($docs); // sort by key (timestamp)               
foreach ($docs as $timestamp =&gt; $path) {
    echo '&lt;li&gt;&lt;a href="/directory/'.basename($path).'" class="'.($counter%2?"light-grey":"").'" target="_blank"&gt;'.basename($path).'&lt;/a&gt;&lt;/li&gt;';
    $counter++;                     
}
</code></pre>

<p>This is probably really easy but I can't seem to be able figure it out - thanks in advance, S.</p>
