I have Android application that sends a json string to PHP server and code is working fine on Android side but what i wants to do is to access JSon object php side and store it into database but i cant access it no matter what. I returned what i was receiving at PHP end to android to see what i am getting.
Thia is what application send to php servere
[
{
"title ": "First entry ",
"address ": "Street 14, Lahore, Pakistan",
"longitude ": "74.322",
"latitude ": "31.5365"
},
{
"title ": "Second entry ",
"address ": "Street 14, Lahore, android ",
"longitude ": "74.322",
"latitude ": "31.5365"
},
{
"title ": "Third entry ",
"address ": "Street 14, Lahore, Lahore ",
"longitude ": "74.322",
"latitude ": "31.5365"
},
{
"title ": "Fgghh",
"address ": "Street 14, Lahore, Pakistan",
"longitude ": "74.3219",
"latitude ": "31.5364"
},
{
"title ": "Shsagcg. ",
"address ": "",
"longitude ": "74.2695",
"latitude ": "31.4626"
},
{
"title ": "Ggggfb",
"address ": "175 Block Q, Lahore, Pakistan",
"longitude ": "74.2693",
"latitude ": "31.4626"
},
{
"title ": "",
"address ": "Street 14, Lahore, Pakistan",
"longitude ": "74.322",
"latitude ": "31.5365"
}
]
Thia is what PHP server send back to application
Array
(
[0] => Array
(
[title ] => First entry
[address ] => Street 14,
[longitude ] => 74.322
[latitude ] => 31.5365
)
[1] => Array
(
[title ] => Second entry
[address ] => Street 14, android
[longitude ] => 74.322
[latitude ] => 31.5365
)
[2] => Array
(
[title ] => Third entry
[address ] => Street 14,
[longitude ] => 74.322
[latitude ] => 31.5365
)
[3] => Array
(
[title ] => Fgghh
[address ] => Street 14,
[longitude ] => 74.3219
[latitude ] => 31.5364
)
[4] => Array
(
[title ] => Shsagcg.
[address ] =>
[longitude ] => 74.2695
[latitude ] => 31.4626
)
[5] => Array
(
[title ] => Ggggfb
[address ] => 175 Block Q,
[longitude ] => 74.2693
[latitude ] => 31.4626
)
[6] => Array
(
[title ] =>
[address ] => Street 14,
[longitude ] => 74.322
[latitude ] => 31.5365
)
)
This is what i receive and i tried to access single value with these commands + here is my php code.
<?php
$data = file_get_contents("php://input");
$arr = json_decode($data, true);
print_r($arr);// This commands return above string in same format.
?>
Commands i tried.
$title = $arr[0]['title'];// No success Eror = Undefined index
$title = $arr(0)// of course not success.
$title = $arr[0][1];
Is there any way to access this array.