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

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -