I am using array_chunk but i want to be able to echo something different for the first array in the chunk. Not sure on how to do this and could not find anything. Any help/guidance would be appreciated.
假设我使用:
foreach (array_chunk($entries, 4) as $row) {
if (the array chunk is the first) {回响<div class="cn_page" style="display:block;"> ;}
else {回响<div class="cn_page"> ;}
}
完整代码如下:
回响
<div id="cn_preview" class="cn_preview"> ;
foreach($entries as $entry){
回响<div class="cn_content" style="top:5px;">
<img src="newsslider/images/polaroidphotobar.jpg" alt=""/>
<h1> .$entry->title. </h1>
<span class="cn_date"> .$entry->modified. </span>
<span class="cn_category"></span>
<p> .$entry->text. </p>
<a href="" target="_blank" class="cn_more">Read more</a>
</div> ;
}
回响</div> ;
回响<div id="cn_list" class="cn_list"> ;
foreach (array_chunk($entries, 4) as $row) {
if (the array chunk is the first) {回响<div class="cn_page" style="display:block;"> ;}
else {回响<div class="cn_page"> ;}
foreach ($row as $entry) {
$i++;
if ($i == 1){回响<div class="cn_item selected"> ;}
else {回响<div class="cn_item"> ;}
回响<h2> .$entry->title. </h2>
<p> .$entry->text. </p>
</div> ;
回响</div> ;
}
回响</div> ;
}
echo <div class="cn_nav">
<a id="cn_prev" class="cn_prev disabled"></a>
<a id="cn_next" class="cn_next"></a>
</div>
</div>
</div> ;