Php Array - String Using -
i want use array string. how can this? shared results , strings
i used code:
var_dump($result);
and result returned string:
"{ "_": { "id": "tracked" }, "success": true, "requesttime": "2013-08-19t13:08:36-07:00", "test": "sometextshere", "data": { "news": { "1": "hello", "13": "new text", }, "date": "2013-08-19t13:08:36-07:00" } }"
the results you've posted json encoded. first need decode it:
$decoded = json_decode($result);
you can either return results object or array. default object , can retrieve results using point-to syntax. want string in test:
echo $decoded->test;
you can chained point-tos traverse object properties:
echo $decoded->data->news;
if prefer work arrays, can add optional argument decode. here same things using array argument:
$decoded = json_decode($result, true); echo $decoded['test']; echo $decoded['data']['news'];
hope helps!
Comments
Post a Comment