Use a loop counter and break
when you want to exit.
$i = 0;
foreach ($butters->users->user as $user) {
$id = $user->id;
$name = $user->screen_name;
$profimg = $user->profile_image_url;
echo "things";
if (++$i >= 10) {
break;
}
}
On the 10th iteration the loop will exit at the end.
There are several variations of this and one thing you need to be choose is whether you want to execute the outer loop condition or not. Consider:
foreach (read_from_db() as $row) {
...
}
If you exit at the top of that loop you will have read 11 rows. If you exit at the bottom it'll be 10. In both cases the loop body has executed 10 times but executing that extra function might be what you want or it might not.