0

我有这个代码片段:

$num_thumbs = 3;
$thumb_p = "<li>\n<div class=\"row-wrapper\">\n";
$i = 0;
$j = 0;
foreach ($thumbs_array as &$thumb_link) {
if ($i == $num_thumbs) {
  $i = 0;
  $thumb_p .= "<div class=\"some-class-2\">" . $thumb_link . "</div>";
  $thumb_p .= "</div>\n";
  if($j == 3)
  {
      $thumb_p .= "</li>\n<li>";
      $j = 0;
  }
  $thumb_p .= "<div class=\"row-wrapper\">\n";
  $j++;
} else {
  $thumb_p .= "\t\n<div class=\"some-class-1\">" . $thumb_link . "</div>";
  $i++;
}
}
$thumb_p .= "\n</div>\n</li>\n";

它应该在每三次出现之后换<div class=\"row-wrapper\"><li></li>

问题是我每次都在底部多出一行:

<li>
<div class="row-wrapper">
</div>
</li>
4

1 回答 1

0

考虑这条线

$thumb_p .= "</li>\n<li>";

它不会给你带来麻烦吗?我认为应该是

 $thumb_p .= "<li>\n</li>";
于 2012-06-28T00:31:54.397 回答