One way:
$counter = 0;
foreach($matches as $match)
{
// do stuff, then...
if ++$counter >= 10 {
break;
}
}
Another way:
for($i=1, $max = min(10, count($matches)); $i <= $max; $i++)
{
$match = next($matches);
// do stuff with $match....
}
If you're not sure the array pointer is at the first element before starting the loop, do a reset($matches) first.
PS: Another way: use array_slice(). 🙂