sending php array with POST android

前端 未结 2 598
伪装坚强ぢ
伪装坚强ぢ 2020-12-17 03:46

I want to send a php array via POST from android to php server and i have this code

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new          


        
2条回答
  •  情话喂你
    2020-12-17 04:22

    You can do something like this :

    List nameValuePairs = new ArrayList();  
    nameValuePairs.add(new BasicNameValuePair("colours[]","red"));  
    nameValuePairs.add(new BasicNameValuePair("colours[]","white"));  
    nameValuePairs.add(new BasicNameValuePair("colours[]","black"));  
    nameValuePairs.add(new BasicNameValuePair("colours[]","brown"));  
    

    where colour is your array tag. Just use [] after your array tag and put value. Eg. if your array tag name is colour then use it like colour[] and put value in loop.

提交回复
热议问题