2015-12-02 60 views
2
{"data":{"tokenId":"cbad508f88a2a8ff47c75426338026de"},"success":true,"error":{"errorCode":"200","errorMsg":"successfully"}} 
{"referredBy":"Dvbrhhv","deviceId":"488014664955832","msisdn":"8358808909"} 

呼應的具體價值,我想從這個數據在PHP的echo只有tokenId我怎樣才能發起好心幫我出想從JSON數據

+1

解碼你的JSON。 http://php.net/manual/en/function.json-decode.php – aldrin27

回答

1

jsonvalid json請檢查您的JSON上this link

$json='{ 
    "data": { 
     "tokenId": "cbad508f88a2a8ff47c75426338026de" 
    }, 
    "success": true, 
    "error": { 
     "errorCode": "200", 
     "errorMsg": "successfully" 
    } 
}'; 

$json=json_decode($json); 
echo $json->data->tokenId; 

使用json_decodeDemo

0

你可以得到它

$jsonResult = json_decode($json ,true); 
echo $jsonResult['data']['tokenId']; 

你可以看到result

<br/> 

輸出:cbad508f88a2a8ff47c75426338026de