Jump to content

Archived

This topic is now archived and is closed to further replies.

altergothen

arrays within arrays within arrays ?

Recommended Posts

I want to be able to echo array items within an array within an array
Here is my array structure:
Please help!
Thanks.

Array
(
    [inside_image] =>
    [items] => Array
        (
            [0] => Array
                (
                    [title] => Bangladesh's Health Nutrition Program Gets 460 Mln USD (RedNova)
                    [link] => http://us.rd.yahoo.com/dailynews/rss/search/health+nutrition.
                    [description] => 10/19/2006 - European food companies are already being asked to ...
                )

            [1] => Array
                (
                    [title] => Member States start compiling health claims lists (Nutraingredients.com)
                    [link] => http://us.rd.yahoo.com/dailynews/rss/search/health+nutrition/SIG=12o66dneo                                                                                 
                    [description] => 10/19/2006 - European food companies are already being asked to ...
                )

            [2] => Array
                (
                    [title] => Good nutrition essential for bone health (Antara News)
                    [link] => http://us.rd.yahoo.com/dailynews/rss/search/health+nutrition/SIG=11f9hhq9g
                    [description] => (Full text of a statement. Contact details below.)
                )

)

    [channel] => Array
        (
            [title] => Yahoo! News Search Results for health nutrition
        )

)

Share this post


Link to post
Share on other sites
The easy part is walking the array, the hard part is knowing the format you need the results returned in! Left me explain that. The only time you really need to walk through an array is when you need to do something to the complete array, like remove slashes or set some elements that may have a certain value or maybe empty. In this case it's different, because you need to format the output as your running through the array. To do that, one needs to know how you want to format the output.


me!

Share this post


Link to post
Share on other sites
<?php
echo $array_name['items']['0']['title'];
echo $array_name['items']['0']['link'];
echo $array_name['items']['0']['description'];
?>

If you need to show each item you will needd to create a loop of some sort

Share this post


Link to post
Share on other sites
I think i figured it out? ..... Correct?
>
>
>
$title = $rss_array['items']['0']['title'];
$link =  $rss_array['items']['0']['link'];
$description =  $rss_array['items']['0']['description'];

echo "<p class='heading'><a href='$link'>$title</a></p><p class='text'>$description</p><a href='$link'>Read Full Article ...</a> ";
?>   

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.