I want to send an array of strings to the server from an Android app using Retrofit. I have no idea how can I send it and receive it in server side:
//api interface...
@FormUrlEncoded
@POST("sendArray.php")
Call<ResponseModel> sendAns(@Field("ans[]") String[] ans);
//sending array in main activity
String[] ans = {"ans1","ans2","ans3"};
Call<ResponseModel> call = apiObject.sendAns(ans);
call.en....
//server side php code to get array
$ans = $_POST['ans[]'];
$ans1 = $ans[1];
I expected the value of $ans1 = "ans2" but we got nothing.