Jump to content

outputting array elements


mattspriggs28

Recommended Posts

I have converted xml into an array with no problems, however I'm having difficulty outputting the various attributes.

 

Here is a sample:

 

[0] => Array
                        (
                            [@attributes] => Array
                                (
                                    [YourId] => 1082-1
                                    [Name] => Woodwards Metals
                                    [Description] => 
                                 )

                        )

 

The bit that is confusing me is the @attributes part. How would I output the 'Name' element for example?

Link to comment
https://forums.phpfreaks.com/topic/228686-outputting-array-elements/
Share on other sites

<?php
$test = array(
    0 => Array(
        '@attributes' => Array(
            'YourId' => '1082-1',
            'Name' => 'Woodwards Metals',
            'Description' => ''
            )
        )
    );
foreach($test as $a)echo $a['@attributes']['Name'], "<br />\n";
?>

Archived

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

×
×
  • Create New...

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.