• Notice regarding image hosts and attachments. See here.

Array Help

Associate
Joined
24 Jun 2005
Posts
249
Got an array from an xml feed but am slightly stuck on how to reference values. Arrays consists as follows:

Code:
Array
(
    [0] => Array
        (
            [name] => xe-datafeed
            [attrs] => 
            [children] => Array
                (
                    [0] => Array
                        (
                            [name] => header
                            [attrs] => 
                            [children] => Array
                                (
                                    [0] => Array
                                        (
                                            [name] => hname
                                            [attrs] => 
                                            [data] => Version
                                        )

                                    [1] => Array
                                        (
                                            [name] => hvalue
                                            [attrs] => 
                                            [data] => 2.45
                                        )

                                )

                        )

                    [1] => Array...

How would i reference the data value 2.45?

Any help would be gratefully received.

Cheers,
Rob
 
Working example in PHP incase anyone wants to play...

Code:
<?php

$arr = array('0' => Array
        (
            'name' => 'xe-datafeed',
            'attrs' => '',
            'children' => Array
                (
                    '0' => Array
                        (
                            '[name' => header,
                            'attrs' => '',
                            'children' => Array
                                (
                                    '0' => Array
                                        (
                                            'name' => 'hname',
                                            'attrs' => '',
                                            'data' => 'Version'
                                        ),

                                    '1' => Array
                                        (
                                            'name' => 'hvalue',
                                            'attrs' => '',
                                            'data' => '2.45'
                                        )

                                )

                        )
			)
		)
	);

echo $arr['0']['children']['0']['children']['1']['data'];

?>
 
Back
Top Bottom