title: Breaking the nested loop
body: <p>I'm having problem with nested loop. I have multiple number of posts, and each post has multiple number of images. </p>
  
  <p>I want to get total of 5 images from all posts. So I am using nested loop to get the images, and want to break the loop when the number reaches to 5. The following code will return the images, but does not seem to break the loop.</p>
  
  <p>
  
  <pre><code>foreach($query-&gt;posts as $post){
          if ($images = get_children(array(
                      'post_parent' =&gt; $post-&gt;ID,
                      'post_type' =&gt; 'attachment',
                      'post_mime_type' =&gt; 'image'))
              ){              
                  $i = 0;
                  foreach( $images as $image ) {
                      ..
                      //break the loop?
                      if (++$i == 5) break;
                  }               
              }
  }
  </code></pre>