Twitter引导程序跨越动态网站

时间:2013-05-07 20:26:18

标签: php html css twitter-bootstrap

我应该如何使用像WordPress这样的CMS生成动态行?

<div class="row-fluid">
  <div class="span6"></div>
  <div class="span6"></div>
  <div class="span6"></div>
  <div class="span6"></div>
</div>

那不起作用。

<div class="row-fluid">
  <div class="span6"></div>
  <div class="span6"></div>
</div>
<div class="row-fluid">
  <div class="span6"></div>
  <div class="span6"></div>
</div>

这有效,但我应该如何编写行的后端?

2 个答案:

答案 0 :(得分:4)

K.I.S.S es

/**
 * Le rows to walk
 */
$rows = array(
    "Can",
    "I",
    "Has",
    "Cheezburger",
    "?"
);

/**
 * Le columns numbers
 */
$columns = 2;
/**
 * Le template for each row
 */
$rowTemplate = '<div class="row-fluid">%s</div>';
/**
 * Look at that function, yeah, it's a freaking cool function, it will chunk your array.
 */
$chuncked = array_chunk($rows, $columns);
/**
 * Foreach for make cool and magical stuffs
 */
foreach($chuncked as $chunk){
    $temp = array();
    foreach($chunk as $string){
        $temp[] = sprintf('<div class="span6">%s</div>', $string);
    }
    printf($rowTemplate,implode(null, $temp)). PHP_EOL;
}

答案 1 :(得分:3)

嗯,你没有足够的描述你正在尝试做什么,所以我假设你正在遍历帖子,并将它们全部存储在$posts变量中,并且html在每个content的{​​{1}}属性中,这基本上是我可以给你的唯一方向:

$post