我有这个专栏图像。我希望它像第一行一样显示在网格视图中,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;
}
尝试以下代码:
$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++;
}