我有这个栏目的图片。我希望它像第一行那样在网格视图中显示,1 2 3,然后下一行是4 5 6。如果我对所有图像只有一个变量名,我该怎么做?
$output = json_decode($output);
foreach($output as $template) {
echo '<a href='.$template->preview_url.' target="_blank"><img src=' . $template->thumbnail_url. '></a>';
echo 'Name:' . ' ' . $template->template_name . '<br>';
echo 'Description:'. ' ' . $template->template_id;
}发布于 2014-12-12 16:01:37
试试下面的代码:
$output = json_decode($output);
$i=1;
foreach($output as $template)
{
echo "<div style='float:left'>";
echo '<a href='.$template->preview_url.' target="_blank"><img src=' . $template->thumbnail_url. '></a>';
echo 'Name:' . ' ' . $template->template_name . '<br>';
echo 'Description:'. ' ' . $template->template_id;
echo "</div>";
if($i == 3)
{
echo "<div style='clear: both'></div>";
$i=1;
}
$i++;
}https://stackoverflow.com/questions/27439147
复制相似问题