【问题标题】:How to print the content of an array in phpfox如何在phpfox中打印数组的内容
【发布时间】:2015-09-17 16:04:31
【问题描述】:

我正在开发一个用PHPfox 编写的遗留应用程序。

在我的一个 view.html.php 文件中有这个foreach 循环:

{foreach from=$aReportSubmissions key=iKey item=aReportSubmission}
    <td>{$aReportSubmission.event_name}</td>
{/foreach}

问题是$aReportSubmission.event_name 是一个数组,它被输出为数组。如何循环遍历此变量并显示各个事件?

PHPfox 使用类似于 Smarty 模板引擎的模板标签。

以下内容对我不起作用:

{foreach from=$aReportSubmission.event_name item=iEvent} {iEvent},{/foreach}

【问题讨论】:

  • implode 没有做你想做的事吗?

标签: php smarty phpfox


【解决方案1】:

我可以看到 $iEvent 内部循环之前丢失了

检查是否有效

{foreach from=$aReportSubmissions key=iKey item=aReportSubmission}
    <td>{foreach from=$aReportSubmission.event_name item=iEvent} {$iEvent},{/foreach}</td>
{/foreach}

【讨论】:

    【解决方案2】:

    试试这个

     {foreach from=$aReportSubmissions key=iKey item=aReportSubmission}
        {$aReportSubmission.event_name|print_r}
    {/foreach}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多