Here is the dump of array, I want to access the values stored in “name” I can’t seem to get that.
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
)
What I am using at the moment is some thing like this:
{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}
but this is not returning the required result can some one guide me. Thanks in advance.
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
Above is the output that is shown over there.
According to your output, the foreach is looping over the items of each array, instead of over the arrays.
Concluding from your syntax of the foreach loop, I assume you are using smarty 2.x. In that case I would advise to remove the name attribute or at least rename it to something else than your item attribute as both will result in a variable. As they are currently named identically this means you will be accessing the foreach loop rather than the item.
See the smarty docs on foreach.