We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Php nested array - How to get a value out

leekey asked
Medium Priority
Last Modified: 2012-05-07

I have a nested array in php:
[field_linkout] => Array
            [0] => Array
                    [nid] => 57
                    [view] => <a href="/content/about">About</a>

            [1] => Array
                    [nid] => 15
                    [view] => <a href="/content/learning" class="active">Learning</a>

            [2] => Array
                    [nid] => 55
                    [view] => <a href="/content/organising">Organising</a>



I need to display only the links in the [view] element.

This is how far I've got:

      foreach ($node->field_linkout as $linkoutarray ) {
            foreach ($linkoutarray as $linkdata => $link)
                print $link[view] . '<br/>';
    } //


But it is displaying the first value of both the [nid] and [view] elements. I just need the [view] value.

Any help would be really appriciated.
Thanks, Lk
Watch Question

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
little explanation:
This is array of array (2 levels). And your code was passing it like it was array of array of array (3 levels).


Thanks Michal - I can see what you mean with regards to 3 levels.
have now changed my code and its working correctly.
Thanks again, Lk
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.