这是数组的转储,我想访问存储在“name”中的值,我似乎无法得到它。
Array
(
[Main_photo] => listing_thumbnail16_10858051461322073003.jpg
[ID] => 16
[Kind_ID] => 1
[Account_ID] => 62
[Plan_ID] => 1
[Pay_date] => 2011-11-23 23:29:53
[Featured_ID] => 0
[Featured_date] => 0000-00-00 00:00:00
[Last_show] => 0000-00-00 00:00:00
[Crossed] =>
[Type] => sale
[Shows] => 3
[Status] => active
[Date] => 2011-11-23 23:29:53
[Rating] => 0
[Rating_votes] => 0
[Cron] => 0
[Cron_notified] => 0
[Cron_featured] => 0
[categories] =>
[headline] => asdasd
[price] => 12|euro
[description] =>
[condition] => 1
[title] =>
[lf_site_url] =>
[description_add] =>
[contact_number] =>
[Path] => automobiles
[Key] => automobiles
[Photos_count] => 1
[count_comments] => 0
[Featured] => 0
[name] => Automobiles
[fields] => Array
(
[0] => Array
(
[Key] => headline
[Type] => text
[Default] =>
[Condition] =>
[Details_page] => 1
[name] => Headline
[value] => asdasd
)
[1] => Array
(
[Key] => price
[Type] => price
[Default] =>
[Condition] =>
[Details_page] => 1
[name] => Price
[value] => € 12
)
)
[listing_title] => asdasd
)
Array
(
[Main_photo] => listing_thumbnail10_11485755481321487877.jpg
[ID] => 10
[Kind_ID] => 1
[Account_ID] => 9
[Plan_ID] => 1
[Pay_date] => 2011-11-17 04:57:45
[Featured_ID] => 22
[Featured_date] => 0000-00-00 00:00:00
[Last_show] => 0000-00-00 00:00:00
[Crossed] =>
[Type] => sale
[Shows] => 4
[Status] => active
[Date] => 2011-11-17 04:57:45
[Rating] => 0
[Rating_votes] => 0
[Cron] => 0
[Cron_notified] => 0
[Cron_featured] => 0
[categories] =>
[headline] => test
[price] => 1|euro
[description] => asdas
[condition] => 1
[title] =>
[lf_site_url] =>
[description_add] =>
[contact_number] =>
[Path] => automobiles
[Key] => automobiles
[Photos_count] => 1
[count_comments] => 0
[Featured] => 0
[name] => Automobiles
[fields] => Array
(
[0] => Array
(
[Key] => headline
[Type] => text
[Default] =>
[Condition] =>
[Details_page] => 1
[name] => Headline
[value] => test
)
[1] => Array
(
[Key] => price
[Type] => price
[Default] =>
[Condition] =>
[Details_page] => 1
[name] => Price
[value] => € 1
)
)
[listing_title] => test
)
我现在使用的是这样的事情:
{foreach from=$listings name='listings_check' item='listings_check'}
{foreach from=$listings_check item='check_array_for_name'}
{$check_array_for_name.name}
{/foreach}
{/foreach}
但这不是返回所需的结果可以有人指导我。提前谢谢。
l 1 1 6 1 2 0 0 0 s 3 a 2 0 0 0 0 0 a 1 1 a a 1 0 0 A a l 1 1 9 1 2 2 0 0 s 4 a 2 0 0 0 0 0 t 1 a 1 a a 1 0 0 A t l 3 1 8 1 2 9 0 0 s 1 a 2 0 0 0 0 0 C 1 1 a a 1 2 0 A C l 2 1 1 1 2 1 0 0 s 7 a 2 0 0 0 0 0 C 1 t 1 a a 1 0 0 A C
以上是显示在那里的输出。
答案 0 :(得分:1)
根据你的输出,foreach循环遍历每个数组的项目,而不是遍历数组。
从foreach循环的语法结束,我假设你使用的是smarty 2.x.在这种情况下,我建议删除name属性或至少将其重命名为除item属性之外的其他属性,因为两者都将导致变量。由于它们目前的名称相同,这意味着您将访问foreach循环而不是项目。