我想逐步将 div id 添加到输出的图像中,但无法弄清楚如何让它工作。例如,第一个图像输出将具有“.featured_1”,下一个将具有“.featured_2”等。
我正在使用的代码
if( function_exists('dfi_get_featured_images') ){
$featuredImages = dfi_get_featured_images();
//Now loop through the image to display your image
if( !is_null($featuredImages) ){
$links = array();
foreach($featuredImages as $images){
$thumb = $images['thumb'];
$fullImage = $images['full'];
$links[] = "<li class='zoom'><img class='zoomImg' src='{$thumb}' alt='' height='{$height}' width='{$width}' /></li>";
}
foreach($links as $link){
echo $link;
}
echo "<div style='clear:both'></div>";
echo "</ul>";
}
}
我失败的尝试
$i=1
foreach($featuredImages as $images){
$thumb = $images['thumb'];
$fullImage = $images['full'];
$links[] = "<li class='zoom featured_".$i."'><img class='zoomImg' src='{$thumb}' alt='' height='{$height}' width='{$width}' /></li>";
$i++;
}