javaphpandroidhttpname-value

Java passing multidimensional array to PHP


I tryied to find some information about this but is a bit difficult since all i found is about javascript instead of java,

I want to know how i can get it in php too because i m not sure how to do it

I am trying to pass an array multidimensional by post, i have no idea how to pass a multdimensional array by java this is my code(i suppose that i only will need to change a few)

    try 
    {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://web");

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        for (int count=0; count < array.length; count++)
        {//this loop is what i need to change but i dont know how to do it
            nameValuePairs.add(new BasicNameValuePair("foto",array[count][0]));
            nameValuePairs.add(new BasicNameValuePair("media",array[count][1]));
            nameValuePairs.add(new BasicNameValuePair("votos",array[count][2]));
        }
        if(nameValuePairs != null) httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));


        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        httpclient.execute(httppost, responseHandler);
    }        

Solution

  • I think you should serialize the data to JSON/XML/CSV format and parse it on the server side. Otherwise it will be not so intelligent code.