【问题标题】:Print specific element of array in smarty在 smarty 中打印数组的特定元素
【发布时间】:2015-03-25 07:00:39
【问题描述】:

我是 smarty 的新手,我想在 smarty 中打印数组的特定元素。 我正在使用 vtiger 开源,而 vtiger 使用 smarty。

我写这个是为了打印数组的一个特定元素。我在 foreach 循环中这样做:

{foreach from=$LISTVIEW_ENTRIES key=j item=LISTVIEW_ENTRY name=listview}
{$LISTVIEW_ENTRIES[2]}

{/foreach}

我正在打印具有{$LISTVIEW_ENTRIES|@debug_print_var}函数的所有数组

它给出了这个:

Array (13)
57 => Accounts_Record_Model Object (1)
   ->rawData = Array (20)
    0 => "Nadine Campbell"
    accountname => "Nadine Campbell"
    1 => "Accidental Discharge of Water"
    cf_763 => "Accidental Discharge of Water"
    2 => "2014-09-07"
    cf_765 => "2014-09-07"
    3 => "Refer to Attorney"
    cf_757 => "Refer to Attorney"
    4 => "Progressive Insurance"
    cf_737 => "Progressive Insurance"
    5 => "2015-02-26 12:52:35"
    modifiedtime => "2015-02-26 12:52:35"
    6 => "42 SW 14 Avenue"
    bill_street => "42 SW 14 Avenue"
    7 => "Delray Beach"
    bill_city => "Delray Beach"
    8 => "Patty Mitrov"
    cf_809 => "Patty Mitrov"
    9 => "57"
    accountid => "57"

现在您能告诉我如何打印该数组中的特定元素吗? 我想从该数组中打印索引#2

【问题讨论】:

  • 请对答案进行投票。谢谢

标签: php smarty


【解决方案1】:

试试这个:-

我的数组格式是这样的:-

    Array (84)
    id_product => "112"
    id_supplier => "6"
    id_manufacturer => "0"
    id_category_default => "2"
    id_shop_default => "1"
    id_tax_rules_group => "7"
    on_sale => "0"
    online_only => "0"
    ean13 => ""
    upc => ""
    ecotax => "0.000000"
    quantity => 0

  {foreach from=$products item=product name=products}
        {$product['id_product']}
  {/foreach}

输出是:- 112

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-07
    • 1970-01-01
    • 1970-01-01
    • 2020-09-27
    • 2016-08-27
    • 1970-01-01
    相关资源
    最近更新 更多