My PHP received this string from an Android app
[{"id":2,"category":"Food%2C%20Drinks%20%26%20Clothes","description":"Nasi%20Lemak%2C%20Teh%20Tarik%20","cost":"5","transactionDate":"2016-10-04"},{"id":3,"category":"Food%2C%20Drinks%20%26%20Clothes","description":"Rori%20Canai","cost":"3"}]
Then after doing $data = json_decode($data,TRUE);
to the string above, it become:
Array
(
[0] => Array
(
[id] => 2
[category] => Food%2C%20Drinks%20%26%20Clothes
[description] => Nasi%20Lemak%2C%20Teh%20Tarik%20
[cost] => 5
)
[1] => Array
(
[id] => 3
[category] => Food%2C%20Drinks%20%26%20Clothes
[description] => Roti%20Canai
[cost] => 3
)
)
But I don't know how to read it. Here's what I did:
//I pass the data above into variable $data
$data = json_decode($data,TRUE);
for ($i = 0; $i < count($data); $i++){
echo "id: ".$data[$i]["id"]. ", desc: ".$data[$i]["description"]. ", cost: ".$data[$i]["cost"];
}
but it just outputs A A A...
*All the data above is already displayed in <pre></pre>