How to Access Array



and apologies for a basic question, I am still a newbie in PHP and MySQL and have come across a complicated array I need some help with.


So far the arrays I have worked with are fairly flat, i.e. 1 row of data with multiple fields, say for example a result based on a single address, so line1, line2, line3, town, etc.


I am now dealing with an external api that returns the following results in xml



{"result":
{
group1 [{"fieldname1":"fieldresult1", "fieldname2":"fieldresult2}]
group2 [{"fieldname3":"fieldresult3", "fieldname4":"fieldresult4}]
}
"message":"OK",
"success":true}


My question is how do I access each of the results,


I am planning on using a foreach statement, and will be calling the result $xmlarray.


I then want to define strings such as $field1, $field2, but not sure how to do this when it seems to be quite a deep array, I am guessing something like:


$field1 = $array([0]["field2"];


As I say, I need someones help just to give me a brief overview here, thanks


No comments:

Post a Comment