【发布时间】:2013-05-02 04:59:50
【问题描述】:
我需要输出以下数组
object(stdClass)#6 (14) { [“子类别”]=> 数组(9){[0]=>对象(stdClass)#31(13){[“id”]=>字符串(2)“10” ["parent_id"]=> string(1) "6" ["name"]=> string(8) "Soup" ["description"]=> string(0) "" ["url"]=> string( 4) "supy" ["meta_title"]=> string(8) "Soup" ["meta_keywords"]=> string(8) "Soup" ["meta_description"]=> string(0) "" ["image" ]=> string(0) "" ["visible"]=> string(1) "1" ["position"]=> string(1) "7" ["path"]=> array(2) { [ 0]=> RECURSION [1]=> RECURSION } ["children"]=> array(1) { [0]=> int(10) } } [ 1]=> object(stdClass)#32 (13) { ["id"]=> string(2) "11" ["parent_id"]=> string(1) "6" ["name"]=> string (12) "Сашими" ["description"]=> string(0) "" ["url"]=> string(7) "sashimi" ["meta_title"]=> string(12) "Сашими" ["meta_keywords "]=> string(12) "Сашими" ["children"]=> array(1) { [0]=> int(10) } } [1]=> object(stdClass)#32 (13) { [ "id"]=> string(2) "11" ["parent_id"]=> string(1) "6" ["name"]=> string(12) "Сашими" ["description"]=> string( 0) "" ["url"]=> string(7) "sashimi" ["meta_title"]=> string(12) "Сашими" ["meta_keywords"]=> string(12) "Сашими" ["meta_description" ]= > string(0) "" ["image"]=> string(0) "" ["visible"]=> string(1) "1" ["position"]=> string(1) "8" ["路径"]=> 数组(2) { [0]=> RECURSION [1]=> RECURSION }
我认为这里有多个 foreach 需要从 ["subcategories"] 输出每个 ["name"]
现在我有以下代码
{foreach name=cats from=$category->name item=n}
<li>
<a href="catalog/{$n->url}" category_id="{$n->id}">
<b>{$n}</b>
</a>
</li>
{/foreach}
仅显示当前类别的一个名称(汤)。 如何从 ["subcategories"] 输出每个 ["name"] ?
【问题讨论】: