php - access complex string data returned by curl -
i'm having trouble accessing data being returned via curl. data returned complex string. complex because uses curly braces , looks array.
i tried access data array, eg. $var['key']
, gave me error: warning: illegal string offset
here returned via curl:
string(1422) "{"transactions": [{"transaction_id":143720,"currency_adjustment":20,"offer_id":null,"offer_name":null,"description":"cash out","timestamp":"11\/19\/14"}, {"transaction_id":143718,"currency_adjustment":-10,"offer_id":null,"offer_name":null,"description":"cash out","timestamp":"11\/19\/14"}, {"transaction_id":143716,"currency_adjustment":-10,"offer_id":null,"offer_name":null,"description":"cash out","timestamp":"11\/19\/14"}, {"transaction_id":143672,"currency_adjustment":0.1,"offer_id":null,"offer_name":null,"description":"referral earnings","timestamp":"11\/19\/14"}]}"
i want gain access of currency_adjustment
.
i tried this:
$response['currency_adjustment']
& {$response['currency_adjustment']}
how can access data in string?
$result = (array)json_decode($response); $data = $result["transactions"]; echo $data[0]["currency_adjustment"];
Comments
Post a Comment