我有一個20個元素的數組,數組中的每個元素都包含一個圖像。我是這樣做的,因此圖像大小交替。三張圖像應該是中等大小,接下來的四張很小,第七張很大。模式應該繼續,直到數組結束。現在我有它的工作,使每第七個圖像很大,其餘的很小。我不確定設置介質圖像的最佳方式是什麼。所以: 數組[]PHP返回數組中的前三個元素,然後是另外三個
[0]
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
[16]
[17]
[18]
[19]
[20]
我想[0],[1],[2],[8],[9],[10],[15],[16],[17 ]都是中型的。
下面是我的代碼如下。
foreach ($images as $image) {
$img_size = "small";
if($i !==0 && $i % 7 == 0) {
$img_size = "large";
}else{
$img_size = $img_size;
}
}
酷,你嘗試過什麼?向我們展示您的代碼無法使用。 – sobol6803 2013-03-10 17:29:06
很酷的項目,但是有什麼問題? – 2013-03-10 17:32:08
更新後的帖子更多的信息。希望現在更清楚。 – user2154299 2013-03-10 18:40:10