如何使用Curl解码Json? [重复]

This question already has an answer here:

I want to echo the word 'Active' from the json.

"status":"Active"

PHP/CURL:

$ch = curl_init("http://ip:port/player_api.php?username=$username&password=$password");
    $headers = array();
    $headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0";

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    $result = curl_exec($ch);
// Now i need to decode the json

Json:

{"user_info":{"username":"test","password":"test","message":"","auth":1,"status":"Active","exp_date":null,"is_trial":"0","active_cons":"0","created_at":"000","max_connections":"1","allowed_output_formats":["m3u8","ts","rtmp"]},"server_info":{"url":"111.111.111","port":"80","rtmp_port":"80","timezone":"test","time_now":"2018-03-20"}}
</div>

As Obsidian Age already said, you cannot use CURL to decode JSON. You can use PHP though:

You can use CURL to get the JSON file (I think you already have that):

$url = 'http://ip:port/player_api.php?username=$username&password=$password';

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
$json = curl_exec($ch);
curl_close($ch);

Then you can use PHP to decode the JSON get the status = active.

$data = json_decode($json, true);

echo $data['user_info']['status'];