For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > April 2005 > Referencing complex associative array









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Referencing complex associative array
Roger Thomas

2005-04-28, 4:04 am

Hi,
I parsed an XML file and pushed the results into an array. My question is, when I assign this array, $result, to Smarty, how do I reference it ?

I have something like:
{section name=feed loop=$news}
<tr>
<td>
{$news[feed].COPYRIGHT}
</td>
</tr>
{/section}


How do I reference, say, the LINK under ITEMS ? Please advise.



If I do a var_dump on $result, it looks like this:

array(10) {
["TITLE"]=>
string(39) "BBC News | News Front Page | UK Edition"
["LINK"]=>
string(47) "http://news.bbc.co.uk/go/rss/-/1/hi/default.stm"
["DESCRIPTION"]=>
string(33) "Updated every minute of every day"
["LANGUAGE"]=>
string(5) "en-gb"
["LASTBUILDDATE"]=>
string(27) "Wed, 27 Apr 05 23:59:27 GMT"
["COPYRIGHT"]=>
string(92) "Copyright: (C) British Broadcasting Corporation, http://news.bbc.co.uk/1/hi/help/3281849.stm"
["DOCS"]=>
string(33) "http://www.bbc.co.uk/syndication/"
["TTL"]=>
string(2) "15"
["IMAGE"]=>
array(3) {
["TITLE"]=>
string(8) "BBC News"
["URL"]=>
string(56) "http://news.bbc.co.uk/nol/shared/img/bbc_news_120x60.gif"
["LINK"]=>
string(21) "http://news.bbc.co.uk"
}
["ITEMS"]=>
array(5) {
[0]=>
array(5) {
["TITLE"]=>
string(31) "Early Iraq legal opinion leaked"
["DESCRIPTION"]=>
string(115) "The attorney general doubted the Iraq war would be legal without a new resolution from the UN, leaked advice shows."
["LINK"]=>
string(79) "http://news.bbc.co.uk/go/rss/-/1/hi/uk_politics/vote_2005/frontpage/4491105.stm"
["GUID"]=>
string(70) "http://news.bbc.co.uk/1/hi/uk_politics/vote_2005/frontpage/4491105.stm"
["PUBDATE"]=>
string(27) "Wed, 27 Apr 05 22:32:09 GMT"
}
[1]=>
array(5) {
["TITLE"]=>
string(32) "Man arrested over Abigail attack"
["DESCRIPTION"]=>
string(96) "A 25-year-old man has been arrested by detectives hunting the man who stabbed Abigail Witchalls."
["LINK"]=>
string(73) "http://news.bbc.co.uk/go/rss/-/1/hi/england/southern_counties/4492119.stm"
["GUID"]=>
string(64) "http://news.bbc.co.uk/1/hi/england/southern_counties/4492119.stm"
["PUBDATE"]=>
string(27) "Wed, 27 Apr 05 23:53:19 GMT"
}
[2]=>
array(5) {
["TITLE"]=>
string(32) "Jackson's ex-wife in witness box"
["DESCRIPTION"]=>
string(122) "Prosecutors in Michael Jackson's child abuse trial begin questioning the star's ex-wife and mother of two of his children."
["LINK"]=>
string(67) "http://news.bbc.co.uk/go/rss/-/1/hi/entertainment/music/4490259.stm"
["GUID"]=>
string(58) "http://news.bbc.co.uk/1/hi/entertainment/music/4490259.stm"
["PUBDATE"]=>
string(27) "Wed, 27 Apr 05 21:58:53 GMT"
}
[3]=>
array(5) {
["TITLE"]=>
string(33) "US terror charge Briton convicted"
["DESCRIPTION"]=>
string(112) "A British man is found guilty of attempting to support terrorism after trying to sell a missile to an FBI agent."
["LINK"]=>
string(50) "http://news.bbc.co.uk/go/rss/-/1/hi/uk/4491181.stm"
["GUID"]=>
string(41) "http://news.bbc.co.uk/1/hi/uk/4491181.stm"
["PUBDATE"]=>
string(27) "Wed, 27 Apr 05 20:07:48 GMT"
}
[4]=>
array(5) {
["TITLE"]=>
string(28) "Airbus A380 completes flight"
["DESCRIPTION"]=>
string(103) "The world's largest passenger plane, the Airbus A380, lands safely, having completed its maiden flight."
["LINK"]=>
string(56) "http://news.bbc.co.uk/go/rss/-/1/hi/business/4488361.stm"
["GUID"]=>
string(47) "http://news.bbc.co.uk/1/hi/business/4488361.stm"
["PUBDATE"]=>
string(27) "Wed, 27 Apr 05 17:32:10 GMT"
}
}
}



--
Roger


---------------------------------------------------
Sign Up for free Email at http://ureg.home.net.my/
---------------------------------------------------
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com