Kyle Kyle - 10 months ago 42
JSON Question

How to return and format an array in php by using curl

I know this maybe an easy question but I am still stucked here.

I am calling an API, this is my code:

$access_token = 'asdfasdfasdfasdf';
$uid = '12345678';
$url = ''.$uid.'&access_token='.$access_token.'&count=5';
$ch = curl_init();
echo $content;

This is what I got:


What I want is having an array of 'statuses' only, because I want to use the data in 'statuses' only.

Anyone can give me a hint? I will be really appreciated.

Answer Source

That is JSON data...use json_decode() to convert to array

$arr = json_decode($content, TRUE);

$statuses = $arr['statuses'];