Log in

View Full Version : Failing to display multi-dimensional array data


Ashiro
06-22-2006, 11:18 AM
I've retrieved data from an XML source which has generated the following associative array layout:


Array (
[xml attr] => Array (
[version] => 1.0 [encoding] => utf-8
)
[xml] => Array (
[status] => logged
[user] => Array (
[sid] => xxxxxxxxxxxxxxxxxxxxxxxxxxxx
[login] => aaaaaaaaaaaaaaaaaaaaa
[email] => aaaaaaaaaaa@gmail.com
[access_id] => 123456
[user_id] => 123456
[space_amount] => 999999999
[free] => 9
[space_used] =>
)
)
)


Now when I try to access any of these values in my template I thought it would be a simple case of:

$box_data[xml][user][sid]

And I would get: xxxxxxxxxxxxxxxxxxxxxxxxxxxx

However, I get: Array[user][sid] displayed.

Am I missing something? When I try this through a seperate PHP page that simply echos that value of the array it displays how you'd expect. What am I missing?

I'd be very gratful if you can help out. :)

I've just this minute answered my own question. It may be worth modifying the "Custom pages" How-To to reflect that:

If you wish to display a multidimensional array then treat it like an object, e.g.

{$box_data['xml']['user']['sid']}

For multi-dimensional arrays:
Use curly braces.
Use single quotes.