开发者

How to create a response that returns an array [duplicate]

This question already has answers here: 开发者_运维百科 Closed 11 years ago.

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜