-2
有麻煩工作如何獲得最後的迭代行,每4把它的,但我需要找到最後一個,所以我可以作出這樣的做一些事情的foreach symfony的2
foreach($gallery->getMedia() as $key => $media)
{
if(($key % 4) == 0) $html .= '<div class="clear"></div>';
$url = $media->dir . '/' . $media->filename;
$html .= sprintf('<li><a href="#photo-%s" class="album_image_wrapper" id="photo_%s" title="%s" alt="%s" target="_blank" class="image-link" rel="slideshow"><div style="background-image: url(\'',
$media->id ,
$media->id ,
$url,
$gallery->name ,
$media->id ,
$this->generateThumbUrl($url, array('width' => 100, 'height'=> 120, 'zoom' => true)),
$media->title,
$galleryID );