android - Sending string arrays to php -
i want send string array php json , retrieve there.
string[] books = {"book1", "book2", "book3", "book4",..};
in json:
list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>; namevaluepairs.add(new basicnamevaluepair("books", books)); httppost.setentity(new urlencodedformentity(namevaluepairs)); ...
in php side:
$books = $_post['books']; $result = json_decode($books); // ok?
or can use below?
$book1 = $result[0];
$jsonstring = '["xxx@gmail.com","yy@gmail.com","rr@gmail.com"]'; $arrayofyouremails=json_decode($jsonstring);
or
$jsonstring = "[\"xxx@gmail.com\",\"yy@gmail.com\",\"rr@gmail.com\"]"; $arrayofyouremails=json_decode($jsonstring);
and yes code right
$books = $_post['books']; $result = json_decode($books);
Comments
Post a Comment