Thumbnails limit max first 6 images I'm using Drupal 7 and create a module for my content thumbnail images frontpage display. Working this:

 if(count($p_detail-&gt;field_slide) &gt; 0){
            $output .= '&lt;div class="right"&gt;';
            $output .= '&lt;ul class="thumbs"&gt;';
            $i=6;
            foreach($p_detail-&gt;field_slide['und'] as $thumb):
                $img_path = $thumb['uri'];
                $img_url = image_style_url('tmb_240x117', $img_path);
                $img_file = '&lt;img src="'.$img_url.'" alt="'.$p_detail-&gt;title.'" /&gt;';


                $output .= '&lt;li&gt;
                                &lt;a href="'.$p_url.'"&gt;
                                    '.$img_file.'
                                    &lt;div class="shadow"&gt;&lt;/div&gt;    
                                    &lt;div class="hoverimg"&gt;&lt;/div&gt;
                                 &lt;/a&gt;
                                &lt;div class="img_no"&gt;0'.$i.'&lt;/div&gt;
                            &lt;/li&gt;';
                $i--;
            endforeach;
            $output .= '&lt;/ul&gt;';
            $output .= '&lt;/div&gt;';
        }


My thumbnails, field_slide and i want only first 6 thumbnails (if have 6 images... for exam, have 2 images, display 2 thumbnails)

How can i do this?
If I understand you correctly then you just need to break out of the foreach loop after you got 6 thumbnails saved in the $output variable. With that addition the end of your loop would look like this:

if ($i == 1) break;
$i--;
endforeach;