Possible Duplicate:
How to convert array to SimpleXML
I'm trying to figure out how I can modify a script that does some SQL stuff so that at the end of the script, return either a straight up array or an array encoded in XML format to the client.
What is the best way to do this? I'm pretty sure you can't just return a variable, but it needs to be encoded with something like HTML or XML.
(Also, I need the client to wait until the array has been received in order to avoid storing files on the server).
Very simple way to return an array is encode it as JSON but this might not be sufficient for your goals. However, take a look on the options provided by JSON. Tutorial is here: http://www.sencha.com/learn/legacy/Tutorial:Creating_JSON_Data_in_PHP
If you want XML, please have a look on this thread: How to convert array to SimpleXML
精彩评论