View Full Version : php array help needed

01-16-2012, 09:11 PM
Greetings. I'm working on a script to interpret XML output from a server script. I have a script that converts the XML into an array. The challenge I'm having is being able to retrieve data from the array based on how this array is created by the script. Here is an excerpt line of the output from the print_r command from $myArray which is the resulting array from the XML output.

Array ( [XMLOutput] => Array ( [0] => Array ( [suggestion] => Array ( [@attributes] => Array ( [data] => my result here ) ) ) [1] => Array ( [suggestion] => Array ( [@attributes] => ... etc - continues this way for all records followed by )))))

I was having trouble with the syntax but figured it out. For your reference if any of you have this same issue here's the answer:

$myresult = $searchResult['XMLOutput'][0]['suggestion']['@attributes']['data'];