php - 动态网站中的 Twitter Bootstrap

标签 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>

这行得通,但我应该如何对行的后端进行编程?

最佳答案

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;
}

关于php - 动态网站中的 Twitter Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16427962/

相关文章:

php - 如何调整研究的这个问题?

php - 缩进文档,忽略问题

php - 我认为我的 Http 类可能正在做它不应该做的工作

html - 我应该为所有浏览器使用几乎标准模式吗?

css - 在浏览器中缩小时菜单会下降

php - Codeigniter 提交用纯 HTML 编写的表单

javascript - 在html中加载脚本序列

javascript - meteor :多云

javascript - IFrame frameborder 0,仅在 Chrome 上捕捉到内容

asp.net - 母版页和内容页