我在Java中有一个数组,我不知道有多少个位置
ArrayList<String> postparameters2send = new ArrayList<String>();
for(int i=0; i<4; i++){
try{
for (int e=0;e<10;e++){
if(group[i][e]==true){
postparameters2send.add("1");
}else if(group[i][e]==false){
postparameters2send.add("0");
}
}
}catch(Exception e){
}
}
Post post = new Post();
JSONArray jdata=post.getServerData(postparameters2send, "http://www.xxxxx.xx/xxx.php");//"xxxx" isnt the real name
我尝试这样做,
$filtros[]= ($_POST);//here i send the array to that variable
print_r(json_encode($_POST))
foreach ($filtros as $valor) {
$envio= mysql_query("INSERT INTO user_trans(id_usuario,id_transporte)
VALUES('206', '".$valor."')");
}
print_r(json_encode($filtros));
11-13 19:41:06.151: E/log_tag(332): Cadena JSon [{"1":"1"}]//$_POST
11-13 19:41:06.191: E/log_tag(332): Cadena JSon [{"1":"1"}]//$filtros
好吧,问题是$filtros
只获得数组的1° 位置,所以只插入一次,数组的第一个元素忽略其余元素
Cadena JSon {"1":"1","1":"0"} //i sent array[3]
Cadena JSon {"1":"1","1":"0","0":"1"} //i sent array[5]