It depends what you're trying to do. If you're looping through results and outputting HTML, then I would recommend you do that in the view. If you're looping through results to do something to your data then outputting that to the view, then that logic would belong in the controller (or model).
I try to keep my views as PHP-free as possible, so when I have to loop through I tend to use alternate syntax for the loop. Here's an example:
<?php foreach ($x as $y) : ?>
<div>
<h2><?php echo $y['title']; ?></h2>
<p><?php echo $y['content']; ?></p>
</div>
<?php endforeach; ?>
The above ensures that should someone that only knows frontend development need to tweak the view, it's very clear what's happening there.
foreach($withResults)loop.