Debojyoti Debojyoti -5 years ago 84
JSON Question

How to post array to a php server in android?

I am using DataOutputStream class to send my data as post data to a php server

DataOutputStream dataOutputStreamRegister = new DataOutputStream(connectionToRegister.getOutputStream());

The last parameter "ddlClubs" i want to send should be like an array.The code in the php server is as follows

foreach($_POST["ddlClubs"] as $key=>$val){

How should i go about doing this as many techniques i saw included deprecated classes like "defaultHttpClient" and "NameValuePairs"

Thanks everyone for your time.

Answer Source

Just format your url accordingly:


This also works with associative arrays, such as:


Unfortunately this has its limits as a url has a maximum length, meaning you cannot put a very huge array into the url.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download