Joomla foreach循环项目:如何只显示1项并停止循环? [重复]

This question already has an answer here:

I need to stop the foreach loop which continues will creating items if they are posted. Because my design is small, I want to show 1 item. The others items, I can show it in a new iframe when they click on the button "Show more", Which I created.

<?php foreach ($this->items as $item) { ?>
    <?php if ($item->published == 0) continue;?>
      //code
  <?php }?>
</div>

'Continue' is a keyword you use when you want to skip the rest of the execution written beneath 'continue' and you command to execute the next step of your loop directly from there. As @Nigel said 'break' is what should be used when you want to come out of your loop any time.