php - 使用 php 和 smarty 以水平方式显示数组数据

标签 php css loops smarty

建议我一个更好的方法来做到这一点。我想以水平方式显示数组结果。

Column1 | Column 2 | Column 3
3 | 7 | 10

现在竖排显示如下

Column1 | Column 2 | Column 3
3
7
10


Array Result : Stored in $result variable and assigned in smarty variable

Array
    (
        [0] => Array
            (
                [1] => 3
                [Value] => 3
            )
        [1] => Array
            (
                [1] => 7
                [Value] => 7
            )
        [2] => Array
            (
                [1] => 10
                [Value] => 10
            )
    )

.tpl code

<div>
    <ul>
       <li>Column1</li>
       <li>Column2</li>
       <li>Column3</li>
       <div class="clear"></div>
    </ul>

    {section name="index" loop=$result}
     <ul>                          
        <li>{$result[index].value}</li>
        <div class="clear"></div>
     </ul>
    {/section}
</div>

最佳答案

将 UL 置于循环之外,并确保 LI 的显示设置为内联或向左浮动。

<ul>
{section name="index" loop=$result}                     
   <li style="float:left;">{$result[index].value}</li>
{/section}
   <br style="clear:both" />
</ul>

关于php - 使用 php 和 smarty 以水平方式显示数组数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/944355/

相关文章:

php - 密码哈希无法登录 codeigniter

带条件的 PHP 随机数生成

python - Pyganim 在 Sidescroller 游戏中的帮助

javascript - 如何使用 jquery 显示点击时的动态数据

php - Symfony 和 Azure 分发包 - Azure 中的 Assets

php - 空合并运算符和 SQL IN 子句

html - 为什么 -webkit-transform : translate3d(0, 0, 0) 搞砸了固定的 child

html - 尝试制作响应式 div

jquery - 将灰度样式应用于图像,直到它滚动到 View 中心

php存储通过ajax传递的同名S_SESSIONS