if($i==6) {
$result .= '<a style="display:none" class="fancybox" data-fancybox-group="gallery" href="'.$value['images']['standard_resolution']['url'].'"></a> '.$caption.PHP_EOL;;}
else {
$result .= "\t".'<a class="fancybox" data-fancybox-group="gallery" href="'.$value['images']['standard_resolution']['url'].'"><img id="thumb'.++$i.'" src="'.$value['images']['low_resolution']['url'].'" alt="'.$value['caption']['text'].'" width="'.$width.'" height="'.$height.'" /></a> '.$caption.PHP_EOL;}
这意味着:对于所有大于 6 的项目$result
是display:none
和 blahblah,对于所有其他项目,$result 是带有标题的图像。
我想补充的是:如果计数器等于 4,则打印“else” $result
,唯一的更改src="'.$value['images']['low_resolution']['url'].'"
是src="'.$value['images']['thumb_resolution']['url'].'"
我认为这可行,但我正在寻找一种更酷的单线方式:D
if($i==6) {
$result .= '<a style="display:none" class="fancybox" data-fancybox-group="gallery" href="'.$value['images']['standard_resolution']['url'].'"></a> '.$caption.PHP_EOL;;}
elseif($i===4) {
$result .= "\t".'<a class="fancybox" data-fancybox-group="gallery" href="'.$value['images']['standard_resolution']['url'].'"><img id="thumb'.++$i.'" src="'.$value['images']['thumb_resolution']['url'].'" alt="'.$value['caption']['text'].'" width="'.$width.'" height="'.$height.'" /></a> '.$caption.PHP_EOL;}
else {
$result .= "\t".'<a class="fancybox" data-fancybox-group="gallery" href="'.$value['images']['standard_resolution']['url'].'"><img id="thumb'.++$i.'" src="'.$value['images']['low_resolution']['url'].'" alt="'.$value['caption']['text'].'" width="'.$width.'" height="'.$height.'" /></a> '.$caption.PHP_EOL;}